5

I'm trying to copy/move files from one hard drive to another hard drive but I do not want the security/sharing permissions to be copied over with the files; instead I want it to use generic/default permissions.

How do I achieve this?

Hyflex
  • 249
  • 3
  • 6
  • 19

2 Answers2

8

The easiest is using robocopy with the right arguments. Robocopy is a robust copy program where you can specifically tell it how to copy the files. It would suit you using it like:

robocopy c:/source c:/destination /e

The "/e" parameter tells it to copy all subfolders and files. As there's no specification on how to copy, it'll only copy the files, no permissions or attributes.

To copy a single file:

robocopy c:/source c:/destination file.exe

Source: http://ss64.com/nt/robocopy.html

Felipe Donda
  • 216
  • 1
  • 3
  • 2
    Works perfectly, I also added `/move` to the end of it so that it deletes from the source folder once copied. – Hyflex Sep 14 '16 at 04:57
  • This seems to contradict [this Microsoft article](https://learn.microsoft.com/en-us/troubleshoot/windows-client/windows-security/permissions-on-copying-moving-files) which states that Robocopy "preserve[s] existing permissions without adding inheritable permissions from the parent folder", regardless of source or target location? Edit: actually [the documentation for robocopy](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/robocopy) does seem to agree with you, but it's all about as clear as mud. – Grismar Nov 22 '22 at 03:59
3

To get around the "Permission Denied Error 5" and ONLY copy the file without any other attributes use:

robocopy c:/source d:/destination *.* /COPY:D

/Copy:D means only copy data.

:D - Data

:A - Attributes

:T - TimeStamps

:S - Security

:O - Owner

:U - aUditing information

So:

robocopy c:/source d:/destination *.* /COPY:DATSOU

will copy Data, Attributes, Timestamps, Security, Owner, aUditing Info - Which is the same as /COPYALL

/COPY:copyflag[s] :: what to COPY (default is /COPY:DAT). (copyflags : D=Data, A=Attributes, T=Timestamps). (S=Security=NTFS ACLs, O=Owner info, U=aUditing info).