Skip to main content
15 events
when toggle format what by license comment
Apr 12, 2023 at 11:36 comment added GrahamMc This saved me so much time when trying to clear an important folder containing hundreds of thousands of empty folders plus a handful of important, non-empty folders in between. For performance reasons I added the switches to not output to the console, and robocopy blazed like a flaming torch through the job: /NFL /NDL /NJH /NJS
Mar 15, 2022 at 19:30 comment added Mr. T This is is one of my all-time most revisited stackexchange answers thank you!!
Feb 23, 2022 at 14:11 comment added David d C e Freitas Be careful of junctions, directory links, file links, etc... they will be followed and can cause some unexpected results. When running it on a Windows Users folder from another drive, be ware of the Music, Documents, Videos links etc.
Dec 26, 2020 at 16:51 comment added Ray Woodcock I think Robocopy requires folder names with spaces to be enclosed in double quotes, and backslashes in path names to be replaced with double backslashes.
Sep 8, 2020 at 23:55 comment added Glenn Slayden This is fantastic. A couple notes; first this correctly solves a reported problem with the accepted answer where directories containing only empty directories would not be removed. It's not trivial to fix in that approach because it requires removal in depth-first order. This robocopy technique fully removes empty structures to any level of depth. Second, it's worth mentioning that no files are actually moved by robocopy here. This is important for performance of course, but it also means that no NTFS file identifier (FRN) numbers or USN journals are unnecessarily changed or recorded.
Aug 7, 2020 at 17:23 comment added user956584 LOVE IT robocopy.exe are in win8 or win10 : ROBOCOPY %temp% %temp% /S /MOVE and its clean my temp from e,pty folders who
Aug 15, 2019 at 10:34 comment added SimonGoldstone Varun thanks. This is an awesome solution. Went through 3.8TB of files across 60,000 folders in about 10 minutes. Not a single file lost, but no more empty directories. Beautiful.
Apr 23, 2019 at 14:36 comment added CharleyDC5 This just did its magic and worked perfectly. Thanks!
Dec 28, 2017 at 20:20 comment added Marcus Mangelsdorf This is a very elegant solution without any third-party software needed. Thank you!
Oct 13, 2017 at 16:37 comment added user198350 Can Robocopy move files to the recycle bin?
Oct 15, 2015 at 14:11 comment added Arioch 'The it even works with UNC paths (at least on win7) ! Brilliant !
Sep 29, 2015 at 19:17 review Late answers
Oct 5, 2015 at 17:29
Sep 13, 2015 at 19:56 comment added Varun Sharma @Arjan I have tested it, and it works perfectly!. To understand its working, its like moving all files to different location, except empty folders, and then deleting the left-behind empty-folders. /MOVE copies the files first, and then deletes the source file after copying. So, as /S is used, it copies the non-empty folders to destination(same folder in the above case). Then, it deletes the empty folders(like, its thinking that empty-folders has already been copied). No, it does not move nested folders into folder1, as ROBOCOPY moves folders recursively.
Sep 13, 2015 at 11:15 comment added Arjan Magic. So this moves all non-empty folders to the very same location they were already in (so does nothing?), and skips empty folders? But then: why would skipping them result in deletion? And wouldn't this move nested folders into folder1? Scary, unless tested well.
Sep 13, 2015 at 10:25 history answered Varun Sharma CC BY-SA 3.0