开发者

Robocopy copy contents of current folder

开发者 https://www.devze.com 2023-02-04 09:45 出处:网络
How would you trans开发者_如何学编程late this xcopy command into Robocopy: xcopy *.* \"C:\\DestinationFolder\\\"

How would you trans开发者_如何学编程late 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.


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.


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"
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号