Discussion forum for all Windows batch related topics.
Moderator: DosItHelp
-
Dos_Probie
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
#1
Post
by Dos_Probie » 20 Sep 2013 08:42
Got a bunch of .mp3 in E:\Music which are all together and been using the below batch which does the job, but now I have the mp3s
scattered in subdirectories as well in E:\Music..Can someone take a look and revise this to get all of them from the different directories now..Thanks DP
Code: Select all
for /f "tokens=*" %%g in ('dir /b "E:\music\*.mp3" 2^>nul') do (
md "%userprofile%\Music_MP3" 2>nul >nul
Move "E:\music\%%g" "%userprofile%\Music_MP3"
)
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#2
Post
by foxidrive » 20 Sep 2013 09:10
I think this is what you want to do... process subdirectories from E:\music and moving MP3 files to "%userprofile%\Music_MP3"
It will create a log file of any MP3 files that have the same filename.
Code: Select all
@echo off
md "%userprofile%\Music_MP3" 2>nul
for /f "delims=" %%g in ('dir /b /s /a-d "E:\music\*.mp3" 2^>nul') do (
echo processing "%%g"
if not exist "%userprofile%\Music_MP3\%%~nxg" (
Move "%%g" "%userprofile%\Music_MP3" >nul
) else (
>>"%userprofile%\Music_MP3\duplicates.txt" echo "%%g"
)
)
pause
-
Dos_Probie
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
#3
Post
by Dos_Probie » 20 Sep 2013 11:19
Thanks Foxi!..Works perfect

, hey if I also have some formats like .wma or .m4a how could I add them as well?
-
foxidrive
- Expert
- Posts: 6031
- Joined: 10 Feb 2012 02:20
#4
Post
by foxidrive » 20 Sep 2013 19:28
It's easy to pushd the folder and then you can just add the filespecs easily
Code: Select all
@echo off
md "%userprofile%\Music_MP3" 2>nul
pushd "E:\music\"
for /f "delims=" %%g in ('dir /b /s /a-d *.mp3 *.wma *.m4a 2^>nul') do (
echo processing "%%g"
if not exist "%userprofile%\Music_MP3\%%~nxg" (
Move "%%g" "%userprofile%\Music_MP3" >nul
) else (
>>"%userprofile%\Music_MP3\duplicates.txt" echo "%%g"
)
)
popd
pause
-
Dos_Probie
- Posts: 233
- Joined: 21 Nov 2010 08:07
- Location: At My Computer
#5
Post
by Dos_Probie » 21 Sep 2013 07:50
Thanks again, works good!..I read about using pushd for multiple file types and you confirmed it..Also works good
for all my video formats and pictures as well..DP
