i need a function that will take adirectory name and return a list of all mp3 files present in that directory and all it's sub directories?

1 view (last 30 days)
i want to get the all (.mp3) file names along with full path in matlab. kindly help me.

Accepted Answer

Image Analyst
Image Analyst on 5 Jan 2015
My attached demo will do that. Just change the file pattern to *.pm3
  4 Comments
Image Analyst
Image Analyst on 7 Jan 2015
Yes. You can make a function that takes a top level folder and then returns a list of all mp3 files within that tree.

Sign in to comment.

More Answers (1)

Geoff Hayes
Geoff Hayes on 2 Jan 2015
Muhammad - look in the File Exchange for a recursive directory listing submission. One such example is Thomas Vanaret's rdir. Using this file, from the current directory, you could try something like
rdir([pwd '/*.mp3'])
or
rdir([pwd '\*.mp3'])
depending upon your OS.
  4 Comments
Geoff Hayes
Geoff Hayes on 3 Jan 2015
The above example is for one directory. For sub-directories you can try
>> rdir([pwd '/**/*.txt'])
21 kb 28-Dec-2014 13:46:46 /Users/geoff/matlab/testing2/KEmode2_G201.txt
224 b 24-Nov-2014 12:30:41 /Users/geoff/matlab/testing2/RealInfo.txt
979 kb 20-Nov-2014 12:08:10 /Users/geoff/matlab/testing2/data.txt
3 kb 24-Nov-2014 09:35:34 /Users/geoff/matlab/testing2/myConv.cpp.txt
341 kb 20-Nov-2014 17:03:56 /Users/geoff/matlab/testing2/myOutput.txt
2 kb 07-Dec-2014 14:21:08 /Users/geoff/matlab/testing2/readString.F.txt
98 b 12-Dec-2014 12:18:03 /Users/geoff/matlab/testing2/test.txt
204 kb 28-Nov-2014 09:13:59 /Users/geoff/matlab/testing2/test2.txt
204 kb 28-Nov-2014 09:14:08 /Users/geoff/matlab/testing2/test3.txt
663 b 10-Nov-2014 08:02:19 /Users/geoff/matlab/testing2/MRSim/Old version docs/DLLs.txt
3 kb 10-Nov-2014 08:02:19 /Users/geoff/matlab/testing2/MRSim/Old version docs/changes.txt
1 kb 10-Nov-2014 08:02:19 /Users/geoff/matlab/testing2/MRSim/Old version docs/disclaimer.txt
3 kb 10-Nov-2014 08:02:19 /Users/geoff/matlab/testing2/MRSim/Old version docs/readme.txt
88 b 10-Nov-2014 08:02:19 /Users/geoff/matlab/testing2/MRSim/Old version docs/version.txt
Note the differences between the above output and the previous example. You may have to experiment with the code to do what you want...

Sign in to comment.

Categories

Find more on File Operations in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!