filenames (of folder contents) to text

Callan Jefferson Davies callan at cruzn.net.au
Fri Nov 26 18:47:13 GMT 2010


> I’d be grateful to know how I can get the filenames of files (or
> selected files) within a folder [but not subfolders] into a text file,
> whether via the clipboard and Paste, or whatever.


Hi Dave,

Yes, the terminal method you linked to would be perfect.

There probably is an app somewhere that can do it graphically, but this 
may be a good introduction to terminal for you :)

Let's assume you really have never used terminal before, here's a step 
by step :

STEP 1 - GET YOUR CURRENT LOCATION
  - In Nautilus, go to the folder you're referring to.
  - Click FILE then PROPERTIES
  - You'll see "Location" - select this text with mouse, right click and 
copy. This is handy instead of having to type it all.


STEP 2 - GET THERE IN TERMINAL
  - Start terminal
  - Type this : cd "
  - Then right click and PASTE that location text in there
  - Finish with another "
  - Press ENTER
  - Note - I only told you to put the "" in there, because this will 
work with any location, including locations with spaces in the name, 
(for example /home/dave/photos 2010). If your location has no spaces (eg 
/home/dave/photos) then technically you don't need the "".


STEP 3 - GET YOUR FILE LISTING
  - Type this : ls -l > list.txt
  - Give it a moment to do its thing
  - If you look back in Nautilus, your file listing will be there


STEP 4 - PLAY WITH OPTIONS
  - You can change the way your output looks, easily!
  - ls by itself gives a listing of files
  - ls -l will provide a detailed listing
  - ls -1 (that's a number one) will provide a simple listing, but one 
file per line, whereas without the -1 you might get multiple columns
  - If you wanted more ideas, try 'man ls' at the terminal, you'll see 
it's quite powerful!



Good luck!

Cheers
Callan



More information about the ubuntu-au mailing list