Jump to content
xisto Community
Sign in to follow this  
NNNOOOOOO

List All Files In A Folder And Subfolders

Recommended Posts

I need to make a txt file of all my music. I need a script of some sort that'll find all music files in a folder and its sub-folders. I do not need the extension nor path listed, just the file name. The script shall create a txt file and put the file names in it, but one name per line.

Share this post


Link to post
Share on other sites

I need to make a txt file of all my music. I need a script of some sort that'll find all music files in a folder and its sub-folders. I do not need the extension nor path listed, just the file name. The script shall create a txt file and put the file names in it, but one name per line.


Are you using linux? That would be very easy if you were.

I don't have an exact command right now (I'm on Windows and a little rusty) but you can open up a terminal and check out the 'ls" and "find" terminal commands and remember that adding > or >> will write the output to a text file.

ls - List the Contents of a directory The command ls is used to the contents of a directory.Options	What it does-l	long listing-R	list current directory and all other directories within current directory-a	list hidden files-CF	list in column format and append '*' to executable files, '@' to symbolic linked files, '/' to directories-r	list in reverse alphabetically order-t	list more recent accessed files firstfilename(s)	Values to matchExamples	What it doesls	only list file/directory names in current directoryls -l	list all file/directory information in current directory(long version)ls -R	list all files in current directories and belowls -lt	list all files, sorted by most recent accessed firstls -lt /etc/rc*	list files in the '/etc/ directory, only starting with 'rc' and sort results by most recent

So something like ls -R > listofmp3s.txt

might work. If not, you might have to experiment a bit with ls or find.


IF you're using Windows, I'm not sure but I could figure out something later if you don't find a solution. I can give you the right linux code later too if you don't figure it out but there are probably 10000 ways to do it with one command. Linux was made for this kinda stuff!

Edit: Oh, I want to add that you can use *.mp3 to only show mp3s. I think it's ls [flags] *.mp3 you can check ls -help for more info on the syntax.
Edited by rob86 (see edit history)

Share this post


Link to post
Share on other sites

Okay, I think I have what you're looking for (which means you can probably ignore my last post)

 

Open up a linux terminal emulator and type one of these in:

 

My mp3 folder is "mp3zz" but you'll have to change the path to suit your needs.

 

Option #1:

 

find mp3zz/ -iname '*.mp3' -fprint listofmp3s.txt

This option will print a list of every mp3 and include the path for example;:

 

mp3zz/ACDC - Blah Blah.mp3

mp3zz/Led Zeppelin - Whatever.mp3

mp3z/SuckyMusicFolder/Backstreet Boys - Who cares.mp3

 

Option #2

 

find mp3zz/ -iname '*.mp3' -fprintf listofmp3s.txt '%f\n'

This will print a list that shows only the filename, like this:

 

ACDC - Blah Blah.mp3

Led Zeppelin - Whatever.mp3

Backstreet Boys - Who cares.mp3

 

 

I hope one of these suits your needs.. if you need more help ask. Not sure of your experience with linux you might have some trouble applying my commands it to your folders

 

!!BONUS!

 

You can sort your finished list alphabetically with this command

 

sort listofmp3s.txt > sortedlistofmp3s.txt

Edited by rob86 (see edit history)

Share this post


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
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.