ROBOCOPY ` C:\DIR_OLD ` C:\DIR_NEW ` /S ` /XF this.txt *.png
My intent was to delete a repetitive file type from a directory tree. The easiest (and safest) solution I found involved copying the directory tree without the offending files using RoboCopy.
- A Utility accessible from PowerShell or the Command Line.
- The Source.
- The Destination
- Include all subfolders.
- i.e. recursively copy the entire directory tree.
/XF this.txt *.png
- Exclude these files:
- Any file named thusly.
- All PNG's.
The pertinent (to me) portions of the readout were as follows:
Total Copied Skipped Dirs : 1069 1068 1 Files : 6553 4126 2427 Bytes : 978.04 m 975.76 m 2.27 m Times : 0:00:16 0:00:14 0:00:00 Speed : 72652614 Bytes/sec. Speed : 4157.215 MegaBytes/min. Ended : Friday, May 29, 2020 4:20:07 PM
Which means, the 2,427 offending files were not copied over, solving my particular problem in a safer manner than deleting them in place, as I am prone to error.
Additional Notes & Observations
- I work offline, so I got an error.
- No Help was available.
- This command pointed me to the next.
- Provided a concise Cheat Sheet.
- There are loads of other switches that I am not covering.
Comparing The Properties of DIR_OLD with DIR_NEW, I found a Folder Count miss-match from that provided by RoboCopy. I do not know why. I'd had a recent Windows Explorer Error while creating DIR_OLD, so that might be an explanation.
DIR_OLD - 6,553 Files, 1,067 Folders
DIR_NEW - 4,126 Files, 1,067 Folders
Finally, since in the greater scheme of things it is unlikely this page provides any Value Added, one may well question why I bother. Simply put, the preceding endeavour took somewhere between 2-3 hours and I wanted something to show for my time beyond the putative programming result. As such, this page is my trophy, it informs my work. Or to put it another way, it is that spoonful of sugar that helps the medicine go down. I didn't spend a few hours discovering a new tool (nice). I spent a few hours researching the content for yet another page... nicer still, the icing on the cake.
Finally, I am told the origin of RoboCopy is RobustCopy. But personally, I'm interpreting it more along the lines of RobotCopy.