I have a set of files in a folder with names like test! - 01.avi
. I want to make a new folder for each file with the same name and then move the file into that folder. I have everything but how to pull in the "!" and copy the file to the folder.
@ECHO OFF
setlocal enabledelayedexpansion
set "sourcedir=Z:\test"
set folder=null
set file=null
PUSHD %sourcedir%
FOR /f "tokens=* delims=?" %%a in ( 'dir /b /a-d "*[720p].*"'
) DO (
SET file=%%a
FOR /f "tokens=1,2,* delims=]-" %%b in ("%%a" "[*] * - * [720p].*"
) DO (
FOR /f "tokens=* delims= " %%e in ("%%c"
) DO (
SET folder=%%e
FOR /l %%f in (1,1,31) do if "!folder:~-1!"==" " set folder=!folder:~0,-1!
MD "!folder!"
MOVE "!file!" .\"!folder!"\
)
)
)
POPD
GOTO :EOF
Thanks for taking a look