Share via

How do I use robocopy to do a task like the File Explorer "Move" (i.e. keep metadata, delete source items, keep destination items), but across drives and with a log? Would the script in Details work?

Anonymous
2024-12-28T22:07:27+00:00

(This is nearly directly copied from a post made on r/WindowsHelp on December 23, 2024, which in turn was a follow-up on a post made to r/DataHoarder on November 16, 2024.)

For context, I am currently running Windows 10 Pro, version 22H2, build 19045.5247, experience Windows Feature Experience Pack 1000.19060.1000.0 on a Lenovo Thinkpad T14s Gen 2 (AMD) with an AMD Ryzen 5 PRO 5650U with Radeon Graphics processor at a base clock frequency of 2.30 GHz and 16 GB of RAM, of which 14.8 GB is usable.

So, here's the standard behavior when trying to transfer folders between drives on Windows using File Explorer (it only lets you do a "Copy"):

Time C:/ Directory To move D:/ Directory
Before Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) Folder 3, Folder 4 Folder 5, Folder 6 (original metadata)
After Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) N/A Folder 3, Folder 4 (altered metadata); Folder 5, Folder 6 (original metadata)

Here's the behavior of the standard File Explorer "Move":

Time C:/ Directory To move Other C:/ Directory
Before Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) Folder 3, Folder 4 Folder 5, Folder 6 (original metadata)
After Folder 1, Folder 2 (original metadata) N/A Folder 3, Folder 4, Folder 5, Folder 6 (original metadata)

Here's what some of the people on r/DataHoarder were mistakenly thinking I wanted to do (thank god I did a dry run of this; otherwise it'd have been a disaster):

Time C:/ Directory To move D:/ Directory
Before Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) Folder 3, Folder 4 Folder 5, Folder 6 (original metadata)
After Folder 1, Folder 2 (original metadata) N/A Folder 3, Folder 4 (original metadata); Task Log File

And here's what I ACTUALLY want to do:

Time C:/ Directory To move D:/ Directory
Before Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) Folder 3, Folder 4 Folder 5, Folder 6 (original metadata)
After Folder 1, Folder 2 (original metadata) N/A Folder 3, Folder 4, Folder 5, Folder 6 (original metadata); Task Log File

Will this script work for that purpose? (note: of two processes {for 2 folders} joined in a batch file):

robocopy "C:\x" "D:\y" /E /J /COPYALL /MOVE /DCOPY:DATE /R:3 /W:5 /TS /FP /BYTES /NP /ETA /LOG:"D:\y\report.log"
robocopy "C:\z" "D:\y" /E /J /COPYALL /MOVE /DCOPY:DATE /R:3 /W:5 /TS /FP /BYTES /NP /ETA /LOG+:"D:\y\report.log"
...

(Detailed description of logging options excluded for now as I assume there are people in this community familiar with them. BTW, the logging options are meant to replicate the logging style of DMDE {software largely targeted at data recovery that I have used as a general inter-drive copy tool} as closely as possible, which remains my secret weapon—it can do everything I want for this task except automatically deleting the source files. Or, in tabular form:

Time C:/ Directory To move D:/ Directory
Before Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) Folder 3, Folder 4 Folder 5, Folder 6 (original metadata)
After Folder 1, Folder 2, Folder 3, Folder 4 (original metadata) N/A Folder 3, Folder 4, Folder 5, Folder 6 (original metadata); Task Log File

...this.)

If the above script can't work for what I want, could you please tell me what needs to be changed? I am particularly worried about potential incompatibilities between /COPYALL, /MOVE, and /DCOPY:DATE...

Windows for home | Windows 10 | Files, folders, and storage

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2024-12-30T07:27:05+00:00

    Hello,

    You can do Ctrl + X to cut files and directories and Ctrl + V to paste them in File Explorer.

    As for your robocopy script, you can do the following:

    robocopy "C:\sourcedirectory" "D:\destinationdirectory" /e /j /copyall /dcopy:date /move /r:3 /w:5 /ts /tp /bytes np/eta/log:"D:\logdirectory\robocopy.log"
    

    And you can change the command to whatever the directories need to be.

    You might want to test the command out before trying it.

    Let me know how this goes.

    Wait, cut-paste allows you to perform a Move across drives with File Explorer? I honestly never thought of that as a possibility... Does it keep the date metadata intact? (Still log-less, and I can do logless inter-drive moves through FreeCommander, so it isn't exactly revolutionary to me, but still cool if true.)

    Anyway, after a seemingly-successful dry run using /L, I tried your command, or rather

    robocopy "C:\x" "D:\y" /E /J /COPYALL /DCOPY:DATE /MOVE /R:3 /W:5 /TS /FP /BYTES /NP /ETA /LOG:"D:\y\report.log"
    

    which is what I assumed you meant (a very minimal modification of my own script), with one of the 17 folders I planned to transfer with the method. It almost worked, but still failed to do what I wanted. Specifically:

    1. The actual top-level folder (named "20240525", filled with files from, you guessed it, May 25, 2024) I wanted to transfer didn't transfer, only its subfolders ("AppData", "ProgramData", and "storage") and their contents, unlike the Move option in File Explorer, which matches my previous experience with using Robocopy.
    2. While the dates created of each folder were retained (unlike my previous experience with using robocopy), the dates modified were not... bizarrely also unlike my previous experience with using robocopy, and definitely not "Move" behavior.

    I can only think of 2 things that might have caused this:

    1. Maybe your "/tp [...] np/eta/" wasn't a typo as I had assumed it was?
    2. I did what I have conventionally done for robocopy and routed my log file into the same directory I sent the copied item(s) into. Perhaps that disrupts things?

    Any ideas of what may have been an issue? Is my desired behavior just not possible using robocopy?

    By the way (this isn't really necessary information, just wanted to say it), as this action had indeed erased my source folder, in order to try and recover the original dates, I did what I had absolutely, positively wanted to avoid the need for by engaging in this process—I made a sector-by-sector image of my laptop's SSD using DMDE, depleting the storage capacity of my external HDD by considerably more than I'd like. Even then, I think the chance of recovery is slim, as

    1. I wasn't quite sure what I should do afterwards, and so spent about 10 minutes engaging in near-normal behavior, which included taking screenshots and saving webpages.
    2. The primary intention of these moves is to wear-level my SSD (and slightly increase the performance of my computer) by exposing a less-worn part of the drive to my pagefile... and my pagefile increased by almost a gigabyte during that time.

    So... yeah. While I now technically have all the other folders on that external drive, I'm still continuing with this question as I'd rather have them not tucked within a monolithic image file I need to use special software to access and because I think it's useful information for other people.

    Was this answer helpful?

    0 comments No comments
  2. Airbus A350 7,375 Reputation points Volunteer Moderator
    2024-12-28T23:14:51+00:00

    Hello,

    You can do Ctrl + X to cut files and directories and Ctrl + V to paste them in File Explorer.

    As for your robocopy script, you can do the following:

    robocopy "C:\sourcedirectory" "D:\destinationdirectory" /e /j /copyall /dcopy:date /move /r:3 /w:5 /ts /tp /bytes np/eta/log:"D:\logdirectory\robocopy.log"
    

    And you can change the command to whatever the directories need to be.

    You might want to test the command out before trying it.

    Let me know how this goes.

    Was this answer helpful?

    0 comments No comments