I have named my files as follows :
<code>01 - Jan 04, 2020 - 102513
01 - Jan 04, 2020 - 102611
01 - Jan 04, 2020 - 102840
01 - Jan 06, 2020 - 183022
01 - Jan 06, 2020 - 195230
</code>
<code>01 - Jan 04, 2020 - 102513
01 - Jan 04, 2020 - 102611
01 - Jan 04, 2020 - 102840
01 - Jan 06, 2020 - 183022
01 - Jan 06, 2020 - 195230
</code>
01 - Jan 04, 2020 - 102513
01 - Jan 04, 2020 - 102611
01 - Jan 04, 2020 - 102840
01 - Jan 06, 2020 - 183022
01 - Jan 06, 2020 - 195230
What I want to do is create a batch file that would go through directory, find 01 - Jan 04, 2020
, create directory 01 - Jan 04, 2020
and move all files with 01 - Jan 04, 2020
to it.
I would like it to scan entire directory and create and move only when files are there.
I’ve tried the following, but can”t figure how to tweek it.
<code>@echo off &setlocal
for /f "delims=" %%i in ('dir /b /a-d *.PDF') do (
set "filename1=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename1:~11,6!"
mkdir "!folder1!" 2>nul
move "!filename1!" "!folder1!"
endlocal
)
</code>
<code>@echo off &setlocal
for /f "delims=" %%i in ('dir /b /a-d *.PDF') do (
set "filename1=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename1:~11,6!"
mkdir "!folder1!" 2>nul
move "!filename1!" "!folder1!"
endlocal
)
</code>
@echo off &setlocal
for /f "delims=" %%i in ('dir /b /a-d *.PDF') do (
set "filename1=%%~i"
setlocal enabledelayedexpansion
set "folder1=!filename1:~11,6!"
mkdir "!folder1!" 2>nul
move "!filename1!" "!folder1!"
endlocal
)
New contributor
Al Goddard is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.