Thursday, November 21, 2019

command line - Make a list of filenames




I'm looking for an easy way to build a list in a txt file of the filenames inside a given directory. Filenames only preferred, though I could trim other fields if necessary.



In terminal, change directory to the required folder, then use the command:




ls > files.txt


This will redirect a list of the contents of the folder to the text file files.txt. You didn't indicate what form the contents of the folder takes. If there are sub-folders present, in addition to a group of files, the folder names will also be included. But, once you have the text version you can sort/edit it any way you desire.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...