Avoid manually creating folders first to move files within them
I have some files, for example
the punisher return.cbr
the punisher new adventure.cbr
undiscovered country america.cbr
undiscovered country canada.cbr
I need to move files in this way
the punisher
|
+--- the punisher return.cbr
+--- the punisher new adventure.cbr
undiscovered country
|
+--- undiscovered country america.cbr
+--- undiscovered country canada.cbr
I test this script
@echo off
setlocal EnableExtensions DisableDelayedExpansion
for /F "eol=| delims=" %%I in ('dir /AD /B /O-N 2^>nul') do if exist "%%I*.cbr" move /Y "%%I*.cbr" "%%I\"
endlocal
but it works only if before I create manually the punisher
and undiscovered country
folders before to run script.
I need to avoid manually creating folders to move files
Solution 1:
Best solution (there are many):
You can use RoboCopy
with the /MOV
parameter and it will create the directory for you.
Example: RoboCopy c:\FromHere\SomeDir c:\ToHereEvenThoughItDoesntExist\SomeOtherDir "%%I" /MOV