简体   繁体   中英

Using a wildcard to copy

So as my last post couldn't find a good soloution without messing around in the registry I'll be using a IF EXIST but I'm having trouble using a wildcard.

xcopy /s "%~dp0Hello\AVeryFormalPenguin.txt" "E:\Users\*\Desktop\TestBat\Oh\" /Y

The * Should find the username for the computer that has the Desktop folder in. I'll be running it on other machines that may or may not have their desktop in the same place though. It should replace the * with my username but I think It's actually trying to find a folder called * . I don't see what I'm doing wrong.

I don't think xcopy can have wildcards in the file name for directories, last time I checked. Maybe with older xcopy you could do it. You could try replacing it with a "for" command with the likes of this:

for /r "c:\folder" %a in ("folder") do @if exist %a copy c:\temp\*.* "%a"

But I can't guarantee anything.

那么,如果您这样尝试:

xcopy /s "%~dp0Hello\AVeryFormalPenguin.txt" "%userprofile%\Desktop\TestBat\Oh\" /Y

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM