Robocopy CLI syntax won't work - windows

I just recently saw that xcopy is deprecated and that Robocopy is recommended.
I tried moving files with it, but couldn't get it to work.
I tried moving files from C:\Downloads\Temp to F:\Temp
Both folders had no files directly under them. Downloads\Temp has about 20 folders, some of which have subfolders, which are eventually filled with files.
With the following syntax, it didn't work:
robocopy C:\Downloads\Temp F:\Temp /move
So I tried giving a wildcard for files:
robocopy C:\Downloads\Temp F:\Temp * /move
Didn't work either. I ended up doing it with xcopy, no problem.
Can someone tell me what I did wrong here?
I'm on Windows Vista Enterprise SP1, as administrator(CMD was also run as administrator)

With the following syntax, it didn't work:
robocopy C:\Downloads\Temp F:\Temp /move
Yes - this says move all files from c:\downloads\temp to f:\temp - only files directly in those directories.
You need the /S switch to say "recursively down the directory stack":
robocopy C:\Downloads\Temp F:\Temp /S /move
Marc

Related

Delete files do not exist in source folder in cmd?

I have two folders that I backup from source to destination folder using command:
xcopy /E /Y /I /D
Now I want to delete files in destination folder that do not exist in source folder.
There is no 'mirroring' option in xcopy. I have 2 suggestions:
1.
you could run xcopy dest source /L > todelete.txt to obtain a list of files which exist in dest but not in source. Then use a for loop to delete these files in dest.
or
2.
Use robocopy which was designed to use the same options as xcopy but has a lot more funtionality. For instance, a /MIR option to mirror one folder to the other. robocopy is included in all Windows versions from Vista on (the Win7 version might run under XP as well - not tested though).
Besides, it is way faster and and and...

How to robocopy subfolders with content and files with a specific prefix

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

Windows cmd shell xcopy to network directory doesn't work

Im trying to make a batch file that will copy all new files and folders from a source folder to an network directory. All the new subdirectories and new files should be copied (backup).
My code:
xcopy "C:\Source" "T:\Backup" /d/i/s/q
(/d for only new files, /i because source is a dir, /s for all the subdirs and files, /q just to supress the copy text)
Source contains both subdirectories and files (.txt).
The first run it copies Everything as it should. When I add a new .txt file to one of the existing subdirectories and run it again I get the message:
"An error occured when the file The directory is not empty. was being created.
The folder "T:\Backup" could not be created.
0 files copied.
(Translated from Swedish so not 100% original)
The thing is when I try this command to a local source like e.g. "C:\test" and do the same procedure it works.
Anyone who can understand why this doesn't work for the network drive?
Should I try Another command such as robocopy?
Skip xcopy and use robocopy with the /E flag instead. It's built into all recent versions of Windows. Free download for XP.
Example:
robocopy c:\source T:\backup /E
That will copy all the files in the "source" folder to the "backup" folder that haven't been copied already.
And if you don't want to have the output shown on the console (equivalent to the /Q option in xcopy):
robocopy c:\source T:\backup /E /LOG:nul
Robocopy must be better because it should create directories with the \E switch. No overwrites for files, just adds a file with extra letters or extension <> command. Still must defrag.
XCOPY "DRIVE LETTER:\windows.old\USERS" "\computername\D\NAME\" /D /E /C /R /I /K /Y /f

DFRS has gone mad. Copying old files back

My Issue
Our DFRs has gone mad and was having issues. It started copying back older versions of files from the destination to the source server.
Users have been updating files in the source server since last nights backup.
I am not sure what has been copied back though.
What I want to do is check the timestamp of files located in \SourceServer\Folder1 (and sub folders) and \TargetServer\Folder1 (and sub folders) and copy the latest version of all files to a separate Folder (say \SourceServer\Folder2)
Then I can restore the other files from last nights backup.
I have seen a way to use Powershell Compare-Object but only using a -referenceObject and a -differenceObject
All help is greatly appreciated.
Thanks in advance
You could use robocopy for that task. Run the following on SourceServer:
robocopy C:\path\to\Folder1 C:\path\to\Folder2 /e /copyall /dcopy:t /xj
robocopy \\TargetServer\Folder1 C:\path\to\Folder2 /e /copyall /dcopy:t /xj /xo
For general troubleshooting of DFS-R see here and here.

Using Robocopy in VS Postbuild - Automatically Overwrite When Moving Files

I tried the following postbuild command in VS to copy all the dlls and other related files into a centralized folder:
robocopy $(TargetDir) $(TargetDir)Bin *.dll *.pdb *.xml /MOVE
It successfully moves them if the Bin folder doesn't have those files yet. But after the second execution, the files are not moved. I am suspecting that it fails because the files in there already exist. Is there a switch to force overwrite without prompting? I looked at the possible switches for robocopy and can't really find the one I am looking for.
I'm guessing that Robocopy is refusing to move files that it detects are the same on subsequent runs. You should be able to force it to do so with the /IS (include same) and /IT (include tweaked) flags - i.e.,
robocopy $(TargetDir) $(TargetDir)Bin *.dll *.pdb *.xml /IS /IT /MOVE

Resources