|
|
|||||||
Hi Iīm doing some local drive file moves and make this script: *************** $source = "c:\source_dir\" $destination = "c:\destination_dir\" SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE $source $destination /E /MOVE /r:2 /w:2" *************** It works fine with directories without spaces... But when trying to copy dir with spaces it wonīt work.. *************** $source = "c:\Documents And Settings\User.old\My Documents\" $destination = "c:\Documents And Settings\User.new\My Documents\" SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE $source $destination /E /MOVE /r:2 /w:2" *************** I have tryed CHR(34) etc. without succeed. So please, KixScript Guruīs, "Pimīp Up My Script" Henry |
||||||||
|
|
|||||||
Hi Henry, welcome. Try re-wrapping your shell like this: SHELL '%COMSPEC% /e:1024 /c ROBOCOPY.EXE "$source" "$destination" /E /MOVE /r:2 /w:2' Use single-quotes, and double-quotes. -Shawn |
||||||||
|
|
|||||||
Not working, Source / Dest are mixed always wrong. Results from different variations below. SHELL '%COMSPEC% /e:1024 /c ROBOCOPY.EXE "$source" "$destination" /E /MOVE /r:2 /w:2' ****************************************************************** ROBOCOPY :: Robust File Copy for Windows :: Version XP010 Started : Wed Jul 28 15:12:02 2004 Source : c:\source dir" c:\destination\ Dest : C:\kix\dir"\ Files : *.* Options : *.* /S /E /COPY:DAT /MOVE /R:2 /W:2 2004/07/28 15:12:02 ERROR 123 (0x0000007B) Accessing Source Directory c:\source dir" c:\destination\ The filename, directory name, or volume label syntax is incorrect. ****************************************************************** SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE "$source" "$destination" /E /MOVE /r:2 /w:2" ****************************************************************** ROBOCOPY :: Robust File Copy for Windows :: Version XP010 Started : Wed Jul 28 15:13:50 2004 Simple Usage :: ROBOCOPY source destination /MIR source :: Source Directory (drive:\path or \\server\share\path). destination :: Destination Dir (drive:\path or \\server\share\path). /MIR :: Mirror a complete directory tree. For more usage information run ROBOCOPY /? or read Robocopy.Doc. c:\source dir\ c:\destination dir\ /E /MOVE /r:2 /w:2 ****************************************************************** SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE '$source' '$destination' /E /MOVE /r:2 /w:2" ****************************************************************** ROBOCOPY :: Robust File Copy for Windows :: Version XP010 Started : Wed Jul 28 15:16:03 2004 Source - C:\kix\'c:\source\ Dest - C:\kix\dir\'\ Files : Options : /COPY:DAT /R:1000000 /W:30 ERROR : Invalid Parameter #3 : "'c:\destination" Simple Usage :: ROBOCOPY source destination /MIR source :: Source Directory (drive:\path or \\server\share\path). destination :: Destination Dir (drive:\path or \\server\share\path). /MIR :: Mirror a complete directory tree. For more usage information run ROBOCOPY /? or read Robocopy.Doc. ****************************************************************** |
||||||||
|
|
|||||||
Source : c:\source dir" c:\destination\ Source - C:\kix\'c:\source\ there's something mixed up in your var creation me thinx. If we oughta pimp yer script, ya should post the entire (current) script that produces this output |
||||||||
|
|
|||||||
ja, looks like maybe you got some mis-matched quotes somewhere. at least post the section where your creating these $vars. |
||||||||
|
|
|||||||
Sorry... my mistake.. ************************************** $source = "c:\source dir\" $destination = "c:\destination dir\" ; 1 attempt ;SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE $source $destination /E /r:2 /w:2" ; 2 attempt ;SHELL '%COMSPEC% /e:1024 /c ROBOCOPY.EXE "$source" "$destination" /E /MOVE /r:2 /w:2' ; 3 attempt ;SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE "$source" "$destination" /E /MOVE /r:2 /w:2" ; 4 attempt SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE '$source' '$destination' /E /MOVE /r:2 /w:2" ************************************** |
||||||||
|
|
|||||||
$source = "c:\"+'"Documents And Settings"'+"\User.old\"+'"My Documents"'+"\" $destination = "c:\"+'"Documents And Settings"'+"\User.new\"+'"My Documents"'+"\" Would this work? |
||||||||
|
|
|||||||
Quote: NO. It would give you: c:\"Documents And Settings"\User.old\"My Documents"\ c:\"Documents And Settings"\User.new\"My Documents"\ |
||||||||
|
|
|||||||
You know, there are several FAQs on the use of quotes! Try assembling the shell command string in its entirety and that way you can see on the console what in fact you are passing. Code: break on If you like what you see, you do: Shell $ShellCMD |
||||||||
|
|
|||||||
$Source = CHR(34)+"C:\source dir"+CHR(34) $Destination =CHR(34)+"C:\destination dir"+CHR(34) SHELL "%COMSPEC% /e:1024 /c ROBOCOPY.EXE $source $destination /E /MOVE /r:2 /w:2" CHR(34) is ASCII for the double quotes Hope this helps, Chris |
||||||||
|
|
|||||||
Single outside, double inside is a lot easier than CHR(34) and vars in strings are evil! |
||||||||
|
|
|||||||
Thanks to everybody for good ideas, this was the working one: ************************* ; SHELL + ROBOCOPY + DIR with spacebars solution $source = '"c:\My Old Documents"' $dest = '"c:\My New Documents"' SHELL 'ROBOCOPY.EXE $source $dest /E /MOVE /r:2 /w:2' ************************* |
||||||||
|
|
|||||||
Vars in strings are still EVIL! |
||||||||
|
|
|||||||
Shell calls often suck. I guess it's because of the mixed environments. A trick that i use is to simply dislay the shell command to the screen, Just prefix the command with a '?'and put the lot in single quotes, this way yu can see exactly what the %comspec% will see. You can then copy/past the displayed line to your command prompt and see any errors. acmp<>< |
||||||||
|
|
|||||||
What's the big problem with vars in strings? With shell commands they can often be the 'most convenient' soloution. acmp<>< |
||||||||
|
|
|||||||
************************* ; SHELL + ROBOCOPY + DIR with spacebars solution $source = '"c:\My Old Documents"' $dest = '"c:\My New Documents"' SHELL 'ROBOCOPY.EXE $source $dest /E /MOVE /r:2 /w:2' ************************* is the same as... ************************* ; SHELL + ROBOCOPY + DIR with spacebars solution $source = "c:\My Old Documents" $dest = "c:\My New Documents" SHELL 'ROBOCOPY.EXE "'+$source+'" "'+$dest+'" /E /MOVE /r:2 /w:2' ************************* is it not? Except for getting rid of the evil vars in strings. |
||||||||
|
|
|||||||
That would work too, and no evil vars in strings in that example. |
||||||||
|
|
|||||||
One should always read the FAQs and use the good old standard KiXtart script header Code:
|