Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Move files, inherit permissions

Nov
257
3
Is there any way to move files, but inherit NTFS permissions in the destination? Or to trivially reset permissions of only the files that were moved (but not necessarily reset permissions of all files in the destination directory)

The best I've come up with so far is to call robocopy /mov, but this requires a bit of additional logic to build a list of the files that need to be moved due to the different syntaxes between TCC and robocopy. Doable, but I'm lazy if there's a shortcut.
 
With an internal TCMD command? Don't think so. But you can do it with SetACL. Hands down the best ACL manipulation command line tool.
 
BTW the command would be something like this:

Code:
SetACL -on <target> -ot file -actn rstchldrn -rst dacl
 
If the files are moved to a different location on the same drive, they will keep their permissions. (Except if you move it to the parent directory.) If they're moved to another drive, TCC doesn't do anything to transfer permissions (you're doing a COPY and then a DEL), so they inherit the permissions of their new folder.
 
With an internal TCMD command? Don't think so. But you can do it with SetACL. Hands down the best ACL manipulation command line tool.
Unfortunately that requires me to keep track of what files were moved to avoid mangling permissions on files already in the destination directory, so this gets complicated quickly.

If the files are moved to a different location on the same drive, they will keep their permissions. (Except if you move it to the parent directory.) If they're moved to another drive, TCC doesn't do anything to transfer permissions (you're doing a COPY and then a DEL), so they inherit the permissions of their new folder.

I realize that, but I was hoping there might be some sort of "and reset permissions" switch I missed, or similar technique to get reliable results without having to worry about whether the source and destination are on the same logical volume or not.

Switching to robocopy-compatible wildcards isn't too challenging for my current needs and will give me a lot better performance when I am crossing network paths so it's probably the best long-term approach.

Thanks all.
 
Just do a COPY followed by DEL.
That's a bit more complicated since a DEL might wipe files that failed to COPY successfully. I can workaround that by going file by file in a loop, but that's incredibly inefficient in terms of processing time (and is significantly less efficient than doing a move and then resetting the permissions)

I'd love to get away from the need to loop through individual files since there can be thousands of them at once in some cases, and I'd also like to avoid having multi-GB files get duplicated and then deleted if I can, although at the end of the day it looks like there's no fix-all solution.
 
I hate to say it, but when I need to do this I usually just use Windows Explorer (on the server itself). Starting with 2008 (or 2008 R2, not sure), moving files in Windows Explorer causes the files to get the permissions of the destination. It used to be moving files within a single volume would always result in the files retaining their original permissions, but that changed (at least when Explorer is used).

And another vote for SetACL... that is by far the best command line ACL manipulation tool...
 
Thanks for the answer. Maybe SetACL will work for me. I need to move a folder containing many files and subfolders with files to a new target folder in the same volume. The new target folder has different permissions than the source. I want the moved files and folders to inherit the permissions of the target folder.

So, using your earlier SetACL example,
SetACL -on <target> -ot file -actn rstchldrn -rst dacl
I would first move the source folder tree to the new target folder in the same volume, then run the SetACL command with the target being the new folder. Would this cause all files in the target folder to inherit the permissions of the target folder? What about subfolders and files in those subfolders?
 
Would this cause all files in the target folder to inherit the permissions of the target folder? What about subfolders and files in those subfolders?
Yes. The target folder and all files and folders it contains (including subfolders) will be reset with inheritance enabled. The DACL will match what is specified by the DACL of the target's parent folder.
 
Is there a way to retain file permissions when the files are moved, other than creating a list of current permissions, and reapplying them? BTW, is there a purpose for file permissions (of the ACL type, not the simple attribute types) on a personal computer, which - by its very name - is used by a single person, not a business?
 
BTW, is there a purpose for file permissions (of the ACL type, not the simple attribute types) on a personal computer, which - by its very name - is used by a single person, not a business?

Business users are not persons?
 
Very small businesses excluded, no, they are not personnel, they are resources, human (using military style cataloging). Do you know of any business today which employs personnel or has a personnel department? Everything is depersonalized. The computers belong to the organization, and their use is likely to be restricted by organization policies. Most importantly, the software and data on the computer do not belong to the person who uses it at the moment, but to the organization.
 
Is there any way to move files, but inherit NTFS permissions in the destination? Or to trivially reset permissions of only the files that were moved (but not necessarily reset permissions of all files in the destination directory)

The best I've come up with so far is to call robocopy /mov, but this requires a bit of additional logic to build a list of the files that need to be moved due to the different syntaxes between TCC and robocopy. Doable, but I'm lazy if there's a shortcut.

More about....Robocopy Commands

Biden
 
Back
Top
[FOX] Ultimate Translator
Translate