The code:
for %%X in ("C:\Info\AUGUST 2011\Checklists\DET1__*") do (echo %%X)
lists the name of the files that I would like to:
- Create a folder with the rest of the filename (after
DET1__
) as the title of the folder - Move that file into that specific folder
I know it shouldn't be that hard, but I am really not familiar with using Windows for shell scripting, and I don't have access to a UNIX-style shell at work.
Best Answer
This is about a hundred times easier in PowerShell, but this should work. Better explanations of what's going on can be found in
setlocal /?
,set /?
andfor /?
. Batch isn't a good language, so we have to do things like usingENABLEDELAYEDEXPANSION
and the use!FILE!
instead of%FILE%
to prevent the batch file from setting the varibales once and never updating it. One key to remember is that filenames and foldernames cannot be the same. So you can't have both a file and a folderfoo
inC:\
, for example.I have not tested these really, so please do so on your own before doing anything.
PowerShell verion: