This line of code fines all folders in a directory that have a certain bit of text in common and copies all the contents of those folders to a new destination.
dir /b /s /a:d "\\SERVER\Path\Directory\*FolderTag" | for /f "delims=\; tokens=3,4,5*" %%a in ('findstr FolderTag') do @xcopy /i /s /y "\\SERVER\Path\Directory\%%b\%%c" "E:\%%b\"
It works like a charm. But I'd like to be able to move the files instead of just copying them so that they are removed from their original location. I can't simply replace xcopy
with move
but I can't figure out how to convert the structure of this loop into one that will work with move. Would it be easier just to write another loop that deletes the files? I doubt rm
instead of xcopy
would work and I'm always a little scared to touch rm
.
I tried putting together a working example batch script but because the loop is so dependent on the path structure, i wasn't able to get it working. So basically my question revolves around my implementation of xcopy
in this loop and how it could be changed to let move
work in its place.