1.

Solve : Variables with embedded blanks?

Answer»

I have a batch file using ROBOCOPY to copy FILES and folders from my C: drive to my shared network drive S:. It works fine when the folder names do not have blank spaces.
I have tried putting the names in quotes. That did not work. Here is the CMD line and the prompt set for the folder name.

Set /p folder=Enter MUSIC File Folder Name:
Robocopy c:\Users\Owner\Music\Recordings\%folder% s:\Shared-Music\%folder% /E

What do i need to do to get folder names with blank?
THANKS
Frank
are you sure you are using quotes around the whole thing like
Code: [Select]robocopy "c:\path\%folder%" "c:\destination\of files\"
and not

Code: [Select]robocopy c:\path\"%folder%" c:\destination\of files\""I put the quotes around the variable name INSIDE the %'s. like this %"folder"%
both in the bat and upon prompt entry (not at the same time).
I will try your suggestion
Thanks
Frank CBFB
This worked!
Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%"

Thanks Frank C
Quote

%"folder"%

I expect you've realised why that won't work...

I hit a snag when I tried to add a log switch.
It failed both inside and outside of the quotes.
The //MIR switch worked OK outside of the quotes

Both of these failed:
Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%" /Log:backup.txt

Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder% /Log:backup.txt" Quote from: FrankGC on August 10, 2009, 02:48:24 PM
I hit a snag when I tried to add a log switch.
It failed both inside and outside of the quotes.
The //MIR switch worked OK outside of the quotes

Both of these failed:
Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%" /Log:backup.txt

Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder% /Log:backup.txt"
I don't see any reason why there is a problem with the first one, but the SECOND one definatly has major flaws. Thanks to all
I made the beginners error of copy and paste into the command line in my .bat file. Who knows what extraneous characters accompanied the /log switch. When I typed it it it worked fine.
Robocopy "c:\Users\Owner\Music\Recordings\%folder%" "s:\Shared-Music\%folder%" /log:MusicBkupLog.txt
Frank C


Discussion

No Comment Found