Question

How would you translate this xcopy command into Robocopy:

xcopy *.* "C:\DestinationFolder\"

Keeping in mind that the current folder where the command is run changes dynamically (and hence the source folder is unknown in advance).

Thanks.

Was it helpful?

Solution

robocopy . "c:\dest"

Note you don't need to specify a wildcard in robocopy, by default it copies everything unless you use the /xf /xd flags to exclude certain files.

OTHER TIPS

Robocopy DOES support wildcards.

You're expecting > robocopy SOURCE DEST but type > robocopy *.txt c:\folderdest\ to copy the current folder. If you look at the output from robocopy it will show "Files : *.txt" and "Source = c:\folderdest"

So in fact you can do > robocopy WILDCARD SOURCE DEST. If you want to use the CURRENT folder you need to use . (as has been mentioned here). So you would use > robocopy *.txt . c:\folderdest\.

Screenshot: http://i.stack.imgur.com/Xyxt4.png

As an addition: If robocopy is started from an administrator console, the current folder "." will point to Windows\system32.

You can use the following commands at the top of your batch file to fix this:

@setlocal enableextensions  
@cd /d "%~dp0"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top