开发者

DOS Batch Array values needing spaces

I'm very well and truely stuck on this. I need to have spaces in an array that I've set for a .bat file and then to run the following code. It doesn't work! Any ideas?

%2 is a variable parsed into this .bat file.

set App_Loc=("c$\Program Files\A B")
for /f "usebac开发者_StackOverflow中文版kq delims=" %%i in %App_Loc% do (
robocopy \\%2\%%i <USER DEFINED LOCATION>
)

Any help would be appreciated!


I'm guessing that you want to take the files in c:\Program Files\A B and run a robocopy of them a server (defined in %2 - the second parameter to the batch script to a user defined location).

I do believe that a lot of the misunderstanding can be alleviated if you spec your requirements. But this script should run giving you some output that can be debugged

set App_Loc="c:\Program Files\A B"
for /f "tokens=*" %%f in ('dir /b %App_Loc%') do (
    robocopy "\\%2\%%~nf.%%~xf" "USER DEFINED LOCATION"
)

This is how I used it in a file called test.bat:

C:\temp>dir "c:\Program Files\A B" /b
ADONETArtifactGenerator_T4CodeGenTemplateCS.vstemplate
Barnaby Weir - Tarot Card Rock.mp3
DisableTaskOffload.reg

C:\temp>test.bat dummy server

C:\temp>set App_Loc="c:\Program Files\A B"

C:\temp>for /F "tokens=*" %f in ('dir /b "c:\Program Files\A B"') do ()

C:\temp>()
robocopy "\\server\ADONETArtifactGenerator_T4CodeGenTemplateCS..vstemplate" "USER DEFINED LOCATION"

C:\temp>()
robocopy "\\server\Barnaby Weir - Tarot Card Rock..mp3" "USER DEFINED LOCATION"

C:\temp>()
robocopy "\\server\DisableTaskOffload..reg" "USER DEFINED LOCATION"

C:\temp>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜