SOLVED: Print Directory list to a file

Suggestions and feedback for Linux Mint and the forums
Forum rules
No support questions here please
Post Reply
quartchug
Level 2
Level 2
Posts: 54
Joined: Mon Feb 04, 2019 10:58 pm

SOLVED: Print Directory list to a file

Post by quartchug »

I would like to be able to get a list of the file names in a directory put into a file. Then I would be able to print the file, or re-arrange names in the file. I am creating a cook book, so there are a lot of recipes (individual files). I would like to group and re-group them, so that eventually I can create a table of contents. I remember in Win10 I found out how to make a little app that I then accessed by left clicking on a directory name. Could that be done in Mint 20.x Cinnamon?
Dell Inspiron 660 (2013) I5-3330 4Gb 1T hdd Linux Mint 20 64-bit Cinnamon desktop
Last edited by quartchug on Sat Jan 02, 2021 5:42 pm, edited 1 time in total.
ugly
Level 4
Level 4
Posts: 413
Joined: Thu Nov 24, 2016 9:17 pm

Re: Print Directory list to a file

Post by ugly »

This should be doable from the terminal.

Navigate to the folder you want to print the files to (or if you're using Cinnamon, then you can use the file explorer to go to the folder you want and right click and pick 'Open in terminal')

Then from the terminal use:

Code: Select all

ls -a >> ~/Desktop/filelist.txt
That will write all the files and directories into a file named filelist.txt on your desktop. You can change the path and filename of the file you want to write to to whatever you want.
Lady Fitzgerald
Level 7
Level 7
Posts: 1646
Joined: Tue Jan 07, 2020 3:12 pm
Location: AZ, SSA (Squabbling States of America)

Re: Print Directory list to a file

Post by Lady Fitzgerald »

I use a program called Filelistcreator. This link describes what it is and how to use it: https://www.ghacks.net/2020/01/28/filel ... and-linux/. However, the link provided is for WIndoze. You can get the Debian package for installing from https://www.sttmedia.com/filelistcreator-download.
Jeannie

Linux Mint Cinnamon 19.3 Cinnamon 64 bit
System 76 Serval WS (serw11) 17" Laptop
nielo
Level 2
Level 2
Posts: 66
Joined: Tue Mar 22, 2011 7:44 pm

Re: Print Directory list to a file

Post by nielo »

Alternatively, open the directory in Nemo, press Ctl+A to select all, Ctl+C to copy, then open Text Editor, in a blank text file press Ctl+V to paste - et voila! Save the text file and there you have a full list of all files in that directory. To get rid of the path press Ctl+H for the "replace" function and type in "/home/username/Downloads/" (where username is whatever yours is) and leave the "Replace with" dialog empty.

If you need to, you can re-sort the filename list alphabetically in Libreoffice or, to save work, just sort the folder contents the way you want in Nemo to start with e.g. Name, Date Modified...
quartchug
Level 2
Level 2
Posts: 54
Joined: Mon Feb 04, 2019 10:58 pm

Re: Print Directory list to a file

Post by quartchug »

These are great products that fill that space. I would like to see the next distribution have it as a native GUI application. Thanks for your thoughts!
User avatar
henderson_bay329
Level 1
Level 1
Posts: 16
Joined: Sun Apr 18, 2021 11:45 am

Re: Print Directory list to a file

Post by henderson_bay329 »

ugly wrote:
Fri Jan 01, 2021 2:30 am
This should be doable from the terminal.

Navigate to the folder you want to print the files to (or if you're using Cinnamon, then you can use the file explorer to go to the folder you want and right click and pick 'Open in terminal')

Then from the terminal use:

Code: Select all

ls -a >> ~/Desktop/filelist.txt
That will write all the files and directories into a file named filelist.txt on your desktop. You can change the path and filename of the file you want to write to to whatever you want.
Just what I needed! Also, in LM 20, I was able to open successive folders, then terminals, and using the up arrow, replicate the command as given above in each successive terminal (i.e., command ls -a >> ~/Desktop/filelist.txt was "remembered" after closing each terminal session, and available to use in the next!). That's NICE! Thanks!
Post Reply