Jump to content

Hi everybody!

Please, I would like your help at the following issue..

On my pc with Ubuntu, I have connected a second hdd. I load Ubuntu from main disk, I go to second disk at root (C:\) from GUI Nautilus in order to search for all pdf. So, in second disk, from menu window I go to:

Go->Search for files

and there I enter pdf. I get the list for all files with Name, Size, Type, Location, Modified. Up to here is all perfect as I want.

The one that I do not know how to do is how may I export this list (with Name, Size, Type, Location, Modified fields) to a spreadsheet (Calc or MS Office Excel).

Is that possible, and if yes, how could I do this?

 

Thank you!

Link to comment
https://linustechtips.com/topic/1025268-file-list-export-to-file/
Share on other sites

Link to post
Share on other sites

Here's a way to export all that information to a text file:

find ~/Documents -type f -follow -print | grep '\.pdf' | grep -ve "'" | xargs -d "\n" ls -lah > pdfs.txt 2> /dev/null

assuming your pdfs are somewhere inside the "~/Documents" folder. You can run this on your home directory, but it will take a long time and produce a lot of errors - it's better to only run it on folders that might contain a pdf file. The output is saved to "pdfs.txt", but obviously you can change that to your liking.

 

To convert that to csv, you can run:

cat pdfs.txt | python2 -c '
import sys
for line in sys.stdin:
    r = line.strip("\n").split(None, 10)
    fn = r.pop()
    print ",".join(r[:7]) + "," + " ".join(r[7:]) + ",\"" + fn.replace("\"", "\"\"") + "\""
' > pdfs.csv 2>/dev/null

which will place everything in pdfs.csv

 

It should all work without the need to install anything, if you have trouble feel free to ask.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×