Reputation: 1
Ive been trying create a batch file that scrubs all drivers and other elements of a computer to a USB flash drive. The batch file is functional but it gathers the data in a ridiculous amount of folders with subdirectories which makes the data useless.
Ive been trying to find a way to collapse or remove the folders and put all the files into one folder.
I found that this command:
for /r "source" %f in (*) do @copy "%f" "target"
works but for some reason wont operate in any batch file.
Does anyone know away to do this? Either move the files to one folder or copy then delete.
Thanks in advance!!!
Upvotes: 0
Views: 558
Reputation: 882606
If you're using %
variables in a batch file, you need double-%
:
for /r "source" %%f in (*) do @copy "%%f" "target"
But you may want to consider what's going to happen to the two files dir1/file.txt
and dir2\file.txt
when you try to put them in the same directory.
By the way, why have you not thought about using xcopy
?
Upvotes: 2