I’m trying to create a standardised directory structure to prepare a drive ready for tidying and migration to a new location. What I’m looking to do is run a batch file in the root of the drive which works through all subdirectories and creates a new folder called ‘Archive’ in each of them ready for files to be tidied up and later moved or deleted.
I’m trying to use FOR /F with an MD command to make the folders, but I’m really struggling to understand the syntax re. tokens and variables. I’m trying to adapt from something like
for /f "tokens=*" %a in ('dir /b /s /a-d') do @copy "%a" "c:\Single-Folder"
which I nabbed from over here replacing @copy with @md… but I’m really out of my depth.
Any offers of help much appreciated
The command you are using:
lists everything except directories (the – sign negates the attribute). So the right command you have to use is this:
(try it yourself!).
FOR /Freads the output of thedircommand, one line of text at a time.tokens=*will get the whole line (removing leading spaces). I think you need this:when you are sure it is right, remove the
echocommand to actually execute themkdir.