Is there a command in CMD/PowerShell to perform a "perfect" cut-paste, where the command only copy file to target when he can delete the source?

Because all my attempts with robocopy and move weren't successful as it was a cut-paste for movable files and a copy-past for non-movable files, so it was difficult to store that many files on a same drive, because it needs nearly double the space with this method. And in final, I don't want the files that can't be moved, only the one that can be

  • 2
    have you determined why the unmovable files cannot be moved? Commented Aug 31, 2021 at 17:32
  • I haven't considering that it's multiple reasons depending on the file, and it's location. And it's totally okay, as I don't want to get the unmovable files. I want to skip them to just get the movable ones
    – aab
    Commented Aug 31, 2021 at 17:34
  • well, alot of the reasons a file can't be moved can't be established until the file has already been copied and it attempts to delete the original. note that there is no difference between a copy followed by a delete, and a cut/move, other than that if the destination is on the same partition, a copy will actually write new data for the file, while a move will just update the filesystem metadata. if the destination is on a different partition, there is no real difference. so as a result, you will need to exclude those files from the copy, and that involves determining what files won't delete. Commented Aug 31, 2021 at 17:38
  • My move technique is extremely slow and massive considering that it takes a tremendous time to create a new file. But considering that I only want to move on the same partition, the operation could be near instantaneous if I just had to update fs metadata, and that's what I want. But I personally have no way to determine which file is moveable. I need something that will only be able to update, not create. So it will not begin a useless operation and create a dupe
    – aab
    Commented Aug 31, 2021 at 17:52
  • Or maybe even something that test deletable data to create a list to effectively move. Or at least, if it's too difficult, I need something that will perform the long copies, but if it can't delete the source, it deletes the target. So it will be long but at least not uselessly big
    – aab
    Commented Aug 31, 2021 at 17:55

1 Answer 1


You can use IsReadOnly property to filter read-only items out before moving:

> Get-ChildItem | 
    Where-Object {-not $_.IsReadOnly} | 
      Move-Item -Destination destfolder
  • Until now I was using the command robocopy $source $target /xd $target /s /dcopy:dat /copy:dat /move /j /nooffload /mt:128 /r:0 /w:0 /log:$target\logs. I will have to tinker with PSH to get those functions in this new command
    – aab
    Commented Sep 1, 2021 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .