Reputation: 77
I'm looking a for loop that will go into the sub directories and move file with extensions mp4 and flv into a folder call Media.
Folder structure is as follows:
Folder 1 (Parent) (Where bat file would go)
Folder 1 Sub (First Sub-folder)
Media (Folder)
File_Name.Mp4
File_Name.flv
Folder 2 Sub (Second Sub-folder)
Media (Folder)
File_Name.Mp4
File_Name.flv
Folder 3 Sub (Third Sub-folder)
Media (Folder)
File_Name.Mp4
File_Name.flv
And so on..... I have about 1100 sub-folders in Folder 1 (parent folder
Thanks for taking a look at this.
Upvotes: 1
Views: 238
Reputation: 37569
change the start folder Folder 1 (Parent)
if necessary and try:
@echo off &setlocal
for /r "Folder 1 (Parent)" %%i in (*.mp4 *.flv) do (
echo("%%~pi"|findstr /ri ".\\Media\\.$" >nul|| echo move "%%~fi" "%%~dpiMedia\%%~nxi"
)
Upvotes: 2
Reputation: 41234
This is designed to process all the 1st level folders in the parent, and move the mp4 and flv files into a folder called media that is inside the first level folder.
It is untested. Test it on some sample folders.
@echo off
for /f "delims=" %%a in (' dir /ad /b ') do (
pushd "%%a"
md Media 2>nul
for %%z in (mp4 flv) do move *.%%z Media
popd
)
Upvotes: 2