I'm trying to drag both folders and files onto a batch file and want to process the filetypes .flac .mp3 .acc
only if the directories/subdirectories contain these filetypes.
Recursive processing is what I was after also.
Dir tree looks like:
Z:\Music\
| 03 - I Love You (Booka Shade Remix).mp3
| 02 - Towers.mp3
|
+---Woodkid - 2013 - I Love You [FLAC]
| cover.jpg
| 02 - Towers.flac
| 01 - I Love You.flac
| 03 - I Love You (Booka Shade Remix).flac
|
+---No FLAC, MP3 or ACC folder
| cover.jpg
|
\---Woodkid - 2013 - I Love You [MP3]
| cover.jpg
| 01 - I Love You.mp3
| 02 - Towers.mp3
| 03 - I Love You (Booka Shade Remix).mp3
|
\---Woodkid - 2013 - I Love You [ACC]
| cover.jpg
| 01 - I Love You.acc
| 02 - Towers.acc
| 03 - I Love You (Booka Shade Remix).acc
I wanted to process the directory tree above like so with files in numerical order.
Processing Directory: Z:\Music\
Processing File: 1 - 02 - Towers.mp3
Processing File: 1 - 03 - I Love You (Booka Shade Remix).mp3
Processing Directory: Woodkid - 2013 - I Love You [FLAC]
Processing File: 1 - 01 - I Love You.flac
Processing File: 1 - 02 - Towers.flac
Processing File: 1 - 03 - I Love You (Booka Shade Remix).flac
Processing Directory: Woodkid - 2013 - I Love You [MP3]
Processing File: 1 - 01 - I Love You.mp3
Processing File: 1 - 02 - Towers.mp3
Processing File: 1 - 03 - I Love You (Booka Shade Remix).mp3
Processing Directory: Woodkid - 2013 - I Love You [ACC]
Processing File: 1 - 01 - I Love You.acc
Processing File: 1 - 02 - Towers.acc
Processing File: 1 - 03 - I Love You (Booka Shade Remix).acc
I've tried to get this to work with help from this post but that's for single file types only.
EDIT: My attempt. Notes and questions inside the code:
@echo off
FOR %%I IN (%*) DO (
ECHO.%%~aI | FIND "d" >NUL
IF ERRORLEVEL 1 (
:: Processing Dropped Files
:: Only need folder (%%~dpI) to repeat once, this repeats for every dropped file.
echo %%~dpI
:: Would be nice if I could set a variable for file types at beginning of script
for /f "tokens=*" %%I in ('DIR /B/OGDN "%%~nI.flac" "%%~nI.mp3" "%%~nI.acc" 2^>NUL') DO (
echo Processing File: %%I
)
) ELSE (
:: Processing Dropped Folders
:: Need the directory echod here (just once).
:: Don't know how to process flac mp3 or acc files within the dropped folder recursively.
:: Be nice if I could set a variable for file types here too.
)
)
@pause