I want to remove the "doc" directory from the folder "C:\test\mentor_20220807hier".
J:\builds\hier_mentor have "ert", "doc", "mgh" as its content. C:\test\mentor_20220807hier\ has "abc", "doc", "klm" as its content. All are directories.
I am using the command :
robocopy J:\builds\hier_mentor\ C:\test\mentor_20220807hier\ * /MIR /MT:128 /XD "doc" /E /xf *.pdb *_g.dll *_g.lib *_g.exe
But, "doc" is not being removed from the destination (C:\test\mentor_20220807hier) although /XD "doc" is being given.
Can anyone please let me know what can be done to remove the "doc" folder here with this robocopy command?
Related
Hi I need to copy a file with timestamp and security from other server. I copied it but the security is not same. The specific user is grant to modify the file. However the copied file missing this specific user.
I tried the below commands
robocopy \\sourceServer\c$\Test \\desSever\c$\Test "new From.txt" /SEC /R:1 /W:1 /NP /TEE
robocopy \\sourceServer\c$\Test \\desSever\c$\Test "new From.txt" /COPY:DATSO /R:1 /W:1 /NP /TEE
Try using /COPYALL or /COPY:DATSOU.
If you are copying/replacing existing files, you may also need to use the flag /SECFIX. Otherwise, make sure to totally remove the files and parent directories so that NTFS permissions can be copied over fresh.
One more thing: there may be conditions that robocopy does not copy inherited permissions. Check to see if the permissions are on the file/directory itself, or if they are being inherited from a parent.
For more information:
https://community.spiceworks.com/topic/367948-robocopy-to-inherit-destination-folder-permissions-to-new-child-folders-files
https://conetrix.com/blog/robocopy-secfix-parameter
https://social.technet.microsoft.com/Forums/ie/en-US/b36748cd-14d1-47a5-9fb6-878ca93ad6fc/robocopy-not-copying-ntfs-permissions
I have a rather interesting issue that I think is logically possible via Robocopy, but I cannot find the correct syntax to accomplish this goal.
Problem:
I am trying to sync a lot of data via two remote shares. IE: robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64
The issue arises due to the fact that the root directory has different permissions than all of the subdirectories. I have close to 1000 subdirectories that makes this tedious and difficult to manually do.
Current Issue
Running 'robocopy "\share1\root" "\share2\root" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' changes ONLY the permissions of the root directory, but not the subdirectories.
Running 'robocopy "\share1\root\subdirectory1" "\share2\root\subdirectory1" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64' DOES result in the desired state, but is far too tedious to do for over 1000 sub directories
Desired Results
Either a robocopy command that would ONLY change the permissions on the subdirectories (and the child elements within those directories) but maintain the perms on the root directory, or another means of accomplishing the above.
Any help would be appreciated!
I guess you can technically use PowerShell to automate looping through your directory tree.
Get-ChildItem -Path '\share1\root' -Directory | Foreach-Object {
robocopy "\share1\root\$($_.Name)" "\share2\root\$($_.Name)" /MIR /SECFIX /SEC /S /E /R:5 /W:2 /MT:64
}
I am trying to use the /if (Include Files) flag for robocopy to provide an array list of all the files I would like to copy.
I successfully did this when setting the source directory just 1 level up (e.g. C:\Documents\Folder), and providing just the filename in the array after /if (e.g /if file1).
However, when I try to set the source directory 2 levels up (e.g. C:\Documents) and pass the entire filepath into /if (e.g if/ C:\Documents\Folder\file1 [no extension on these files]), the robocopy will not recognise the entire filepath as a valid parameter. I tried with just one filepath instead of an array, and multiple ways of inputting this such as with double quotes around the filepath, but still errored with invalid parameter.
To test, I tried to do the opposite with /xf, and the robocopy then excluded this file successfully.
Is this a limitation of the /if flag for robocopy?
robocopy C:\Documents D:\Documents /e /tee etc... /if "C:\Documents\Folder\file1"
Thanks.
The /if option is for creating robocopy jobs. It supports only filters, not paths. So you could do:
robocopy C:\Documents D:\Documents /e /if *.pdf /save:myjob
The robocopy syntax allows specifying file names to copy, but not paths:
robocopy C:\Documents\Folder D:\Documents\Folder file1 file2
(Note: The filenames specified here and with the /if option are combined.)
If your files all reside in the same folder, you can just specify all their names. If they are in different folders, you have to run the command for each folder.
For example
I use "robocopy /move /s /e"
to cut C:/folder1/folder2/folder3/
and paste into D:/library/
but I only get D:/library/folder4/folder5/folde6
Where did folder3 go?
edit 1: it's supposed that within folder3 pre-exist folder4, folder5 and folder6.
edit 2: Here's what I'm trying... robocopy /move /s /e "%1" "D:\library"
edit 3: Registry code
edit 4: Expected context menu in W10.
The basic syntax of the Robocopy command is
robocopy source-directory destination-directory [pattern...] [options]
If no pattern is given, the default pattern is *.*.
The querent probably said something like
robocopy C:\folder1\folder2\folder3 D:\library /move /s /e
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ ^^^^^^^^^^^
source directory destination options
This command tells RoboCopy to move all (the default pattern in *.*) the files and directories it finds in C:\folder1\folder2\folder3 to D:\library. Robocopy did that as expected.
To move the directory folder3 from C:\folder1\folder2 to D:\library, the command is
robocopy C:\folder1\folder2\folder3 D:\library\folder3 /move /e
^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^ ^^^^^^^^
source directory destination options
Robocopy will create the destination directory D:\library\folder3 if needed. Note that the option /e implies /s.
Since the question appears to refer to how to do it in batch file, and assuming that %1 does not end in a backslash, I suggest to replace robocopy /move /s /e "%1" "D:\library" with
robocopy /move /s /e "%1" "D:\library\%~nx1"
The /MOVE option deleted the source folder, folder3 in this case, after copying to the new destination.
I see you are using both /s and /e. I think you may want to simplify your command and choose either /s, which will not copy empty directories, or /e which WILL copy empty directories.
It is hard to believe but I seem to be not able to copy a folder with all its files (that begin with a certain character) and subfolders (beginning with the same character) to another folder in Windows 7. I used copy, xcopy and robocopy but all I do achieve is, that all files in the top level directory and all the subdirectories but without their content get copied. What am I doing wrong? I tried several ways, my last try was:
robocopy path\path\here x* path\path\there /E
I also tried
/COPYALL
/MIR
but with the same result.
Your robocopy syntax is incorrect. Is should be:
robocopy path\path\here path\path\there x* /E
ROBOCOPY path\path\here path\path\there \*.* /E