Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I recursively list all files of type *.mp3 in a Windows .bat file?

I want to recursively list the absolute path to all files that end with mp3 from a given directory which should be given as relative directory.

I would then like to strip also the directory from the file and I have read that variables which are in a for-scope must be enclosed in !s. Is that right?

My current code looks like this:

for /r %%x in (*.mp3) do (     set di=%%x     echo directory !di!     C:\bla.exe  %%x !di! ) 
like image 459
clamp Avatar asked Jun 01 '10 15:06

clamp


People also ask

How do you get a list of all files in a folder and subfolders in Windows?

Substitute dir /A:D. /B /S > FolderList. txt to produce a list of all folders and all subfolders of the directory. WARNING: This can take a while if you have a large directory.

Which command is used to see all the files and subfolders?

The dir command displays a list of files and subdirectories in a directory. With the /S option, it recurses subdirectories and lists their contents as well.

How do I print all files in a folder recursively?

How to get a recursive directory listing in Linux or Unix. Try any one of the following commands to see recursive directory listing: ls -R : Use the ls command to get recursive directory listing on Linux. find /dir/ -print : Run the find command to see recursive directory listing in Linux.


1 Answers

Use the command DIR:

dir /s/b *.mp3 

The above command will search the current path and all of its children. To get more information on how to use this command, open a command window and type DIR /?.

like image 100
Matthew Whited Avatar answered Sep 29 '22 02:09

Matthew Whited