Solved Move folder based on extension within folder

March 26, 2012 at 11:41:42
Specs: Win 7 x64
I'm looking for a batch file that would move a folder based on a specific filetype within the folder.
Inside that folder is an *.avi file. I want the batch to be able to move the folder /Test1 to D:/Movies/avi (pre-existing folder) and keep the folder name /Test1. The output would be:
And the batch would check all folders in D:/Movies for .avi files an move the folder try are in

See More: Move folder based on extension within folder

Report •

March 26, 2012 at 14:42:30
✔ Best Answer
Change the paths to suit your needs:


@echo off
if not exist d:\movies\avi mkdir d:\movies\avi >nul
for /f "tokens=*" %%i in (
'dir /b /s *.avi'
) do (
echo move %%~dpi. "d:\movies\avi" >nul

If the output looks correct, remove the echo.


Report •
Related Solutions

Ask Question