2

How would I change this to find .mp3 and move to specified directory?

@echo off
set extlist=mkv mp4 mp3
set rootfolder="C:\Users\Fred\Downloads\uTorrent\Downloads\Complete"
pushd %rootfolder%
if not ["%cd%"]==[%rootfolder%] echo Aborting as unable to change to %rootfolder% && goto End
attrib /s /d -r
for %%a in (%extlist%) do attrib /s *.%%a +r
del. /s /q
for /r %%a in (.) do rd "%%~a"
:End
popd

2 Answers2

3

If you just want all MP3s from all sub-directories to one specified directory (without sub-directories) you can do the following:

@echo off
mkdir g:\someplace
set rootfolder="C:\Users\Fred\Downloads\uTorrent\Downloads\Complete"
for /r %rootfolder% %%f in (*.mp3) do move /Y "%%f" g:\someplace

This will however overwrite any duplicates in the destination. So make sure all MP3s have unique names. This also won't delete empty directories from the source after the MP3s are moved out.

Rik
  • 13,309
2

This PowerShell command will move files in $inputDir and subdirectories that match $filterExt to $outputDir:

$inputDir = "C:\Users\Fred\Downloads\uTorrent\Downloads\Complete";
$outputDir = "E:\MP3Files";
$filterExt = "*.mp3";

Get-ChildItem -Path $inputDir -Recurse -Filter $filterExt | Move-Item -Destination $outputDir

I'm assuming you have a version of Windows new enough to use PowerShell and don't actually need to use DOS batch file?

miken32
  • 559