i am using a Windows 10 64bit laptop to copy a bunch of folder and files to a SharePoint folder.
My Script is running in PowerShell.
If i try to copy the files and folders with the explorer (strg+c and strg+v) everything except .exe files are copying.
.exe files are blocked from the server.
If Robocopy is trying to copy the same set of folders and files:
First i use: Get-Credential
then: Connect-PnPOnline
and then copying with Robocopy.
If i copy the complete bunch of the folder i use following code:
ROBOCOPY $orgPath $newPath /MIR /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
*.* /S /E /DCOPY:DAT /COPY:DAT /PURGE /MIR /R:0 /W:1
If i just copy single files i use:
ROBOCOPY $orgPath $newPath $fileName /dcopy:DAT /copy:DAT /r:0 /w:1
Robocopy is then working with this options:
/DCOPY:DAT /COPY:DAT /R:0 /W:1
$orgPath = the path of the folder i want to copy (local or network drive)
$newPath = the path of the folder where i want to copy to (SharePoint)
$fileName = the file i want to copy
I just copy if the folder/file is not existing already.
With both versions i get the same result.
This is working fine. Robocopy is copying.
The folders and the most files (.xmlx .txt) are copying
The .exe files get the error 222 because the server is blocking this file. That is normal and i understand why he is doing it.
BUT:
.pdf files do not copy with robocopy. This files gives the error 64 (0x00000040).
So the server is not blocking this file. (i also can copy this file using the explorer) but all the .pdf files getting this error using robocopy.
But of course the connection is still working. robocopy is still copying further the .xmlx and .txt files.
The error is relating to the extension.
But i do not know why and i do not know how to solve the problem.
The Name of the .pdf files do not have any special caracters.
Does anyone can help me to fix the problem?
Thanks in advance
With best regards
Matze
Related
I am trying to move files from single source to multiple destination folders . Below is the command that is working perfectly.
robocopy C:\source C:\destination
robocopy C:\source C:\destination1 /MOV
After moving to Destination1, Files are deleting from the source directory. It is working fine. But I am trying to move only files which are not empty .
Below are the commands that I am using
robocopy C:\source C:\destination /MN:1
robocopy C:\source C:\destination1 /MOV /MN:1 `
I am getting this error on cmd.
ERROR : Invalid Parameter #3 : "/MN:1"
Any suggestions would be greatly appreciated.
Finally I found issue. There was a wrong command MN:1. Below is the correct one.
Echo off
robocopy C:\src C:\dest1 /min:1
robocopy C:\src C:\dest2 /MOV /min:1
robocopy C:\src C:\dest1 /min:1 This line copies not empty files from source to destination.
robocopy C:\src C:\dest2 /MOV /min:1 This line moves not empty files from source to destination.
I used robocopy to copy just pdf's from an external hard drive and place them on our server.
source destination *.pdf
It copied over all the folders and subfolders even if there wasn't a .pdf file in the folder. Can someone help me either....
a) Delete empty folders or b) Copy over only folders and subfolders that have .pdf's in them?
Thank you!
Use the following command for copy over only folders and subfolders that have an extension in them in this case ".pdf"
ROBOCOPY sourcePath destPath *.pdf /MIR /S
This will only all files with that extensions and folders that have files with that extension and does not include empty folder.
Try using this ROBOCOPY command for deleting empty folders:
ROBOCOPY myfolder myfolder /S /MOVE
Here source and destination both are 'myfolder'.
I want to mirror two folders, but to exclude certain file types (e.g. js files). I can do that with /XF option.
The problem I run into is that if there is a folder Foo with js file in Destination folder, but there is no Foo folder in Source folder - robocopy command bellow deletes the Foo folder on the destination side together with the js files in it.
Robocopy.exe d:\Source d:\Destination /E /PURGE /XF *.js /COPYALL /FFT
What I would like is to exclude from deliting folders that contain excluded files.
You can't. If you apply /PURGE it will delete, it will delete any file/folder that doesn't exist in your source folder.
If you need to maintain that folder, you need to create that folder in the source and remove the /PURGE switch.
Robocopy.exe d:\Source d:\Destination /E /XF *.js /COPYALL /FFT
I am trying to run a robocopy script in PowerShell so I can insert it into my other PowerShell script:
$SERVERPATH = "E:\Cisco Config Backups"
$NETWORKPATH = "\\SERVER\Cisco Config Backups"
robocopy $SERVERPATH $NETWORKPATH /E /XC /XN /XO /R:0 /W:0 /COPY:T /LOG:C:\logs\robocopy_logs\config_copy.log /TEE /NP
However when I run this code I see robocopy working where it gives me the following output:
ROBOCOPY :: Robust File Copy for Windows
Started : Thursday, June 30, 2016 1:52:56 PM
Source : E:\Cisco Config Backups
Dest : \\SERVER\Cisco Config Backups
Files : *.*
Options : *.* /TEE /S /E /DCOPY:D /COPY:T /NP /XO /XN /XC /R:0 /W:0
But nothing gets copied over, I want to use robocopy for the logging and so I can have it skip files that already exist.
Please let me know if I am doing anything wrong.
The /COPY:T criteria is specifying to only copy file timestamps, so it is not copying the actual data of the file. However, since there are no files on the destination to copy the timestamps to, nothing happens.
You need to specify at least /COPY:DT so that the file data will be copied, but you can probably just remove the /COPY switch completely as you likely want the file attributes as well, which will get copied by default along with the file data and timestamps.
From robocopy /?:
/COPY:copyflag[s] :: what to COPY for files (default is /COPY:DAT).
(copyflags : D=Data, A=Attributes, T=Timestamps).
(S=Security=NTFS ACLs, O=Owner info, U=aUditing info)
You also need to review all of the switches you are using as some are conflicting--not sure what robocopy does in those cases. As Matt points out in the comment below, you have /E and /S. Do you want to copy empty subdirectories or not? /E specifies to copy empty directories, but /S specifies to NOT copy empty directories.
I want to sync folders between two computers, one with XP and one with Vista. I want the two folders mirrored, except for security settings and folder settings. It is my understanding that /MIR switch will delete any 'extra' files in the destination folder, which would include the desktop.ini files. I can avoid copying desktop.ini files with /XA:SH How can I prevent robocopy from deleting the destination desktop.ini files?
If I have to do any extra scripting, I prefer PowerShell. But I hope robocopy can do it on its own.
Thanks.
/XF desktop.ini
Will exclude Desktop.ini (from copy or purge).
Replace the /MIR switch with /E, and don't use the /PURGE parameter.
Explanation: /MIR is the equivalent of using /E /PURGE, so by using /E without /PURGE, you achieve the results you desire.
Create a bat file so you can mirror the source at the destination and later once the mirror process is finish erase the files you desired.
For example:
robocopy SOURCE DEST /E /PURGE or /MIR or /E
command to erase recursively (test the command before running at production):
del /s DRIVe:\DESTINATION\desktop.ini
Hope this helps,
Luis