Henry
(Fresh Scripter)
2004-07-28 02:13 PM
SHELL + ROBOCOPY + DIR with spacebar problem

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


ShawnAdministrator
(KiX Supporter)
2004-07-28 02:17 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

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



Henry
(Fresh Scripter)
2004-07-28 02:35 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

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.
******************************************************************


JochenAdministrator
(KiX Supporter)
2004-07-28 02:45 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

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



ShawnAdministrator
(KiX Supporter)
2004-07-28 02:56 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

ja, looks like maybe you got some mis-matched quotes somewhere. at least post the section where your creating these $vars.

Henry
(Fresh Scripter)
2004-07-28 03:12 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

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"

**************************************


Stanley
(Starting to like KiXtart)
2004-07-28 04:23 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

$source = "c:\"+'"Documents And Settings"'+"\User.old\"+'"My Documents"'+"\"
$destination = "c:\"+'"Documents And Settings"'+"\User.new\"+'"My Documents"'+"\"

Would this work?


Les
(KiX Master)
2004-07-28 04:34 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

Quote:

Would this work?




NO.

It would give you:
c:\"Documents And Settings"\User.old\"My Documents"\
c:\"Documents And Settings"\User.new\"My Documents"\


Les
(KiX Master)
2004-07-28 04:37 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

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
$_ = SetOption('WrapAtEOL','on')


$source = '"c:\source dir\"'
$destination = '"c:\destination dir\"'

$ShellCMD = '%comspec% /c robocopy ' + $source + ' ' + $destination + ' /E /MOVE /r:2 /w:2'

$ShellCMD ?


If you like what you see, you do:
Shell $ShellCMD


Chris_Wood
(Lurker)
2004-07-28 06:09 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

$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


Les
(KiX Master)
2004-07-28 07:03 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem

Single outside, double inside is a lot easier than CHR(34) and vars in strings are evil!

Henry
(Fresh Scripter)
2004-07-28 08:10 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

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'
*************************


Les
(KiX Master)
2004-07-28 08:30 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

Vars in strings are still EVIL!

acmp
(Getting the hang of it)
2004-07-28 09:55 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

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


acmp
(Getting the hang of it)
2004-07-28 09:57 PM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

What's the big problem with vars in strings?

With shell commands they can often be the 'most convenient' soloution.

acmp<><


ShaneEP
(MM club member)
2004-07-29 12:42 AM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

*************************
; 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.


Les
(KiX Master)
2004-07-29 12:47 AM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

That would work too, and no evil vars in strings in that example.

Sealeopard
(KiX Master)
2004-07-29 04:11 AM
Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved

One should always read the FAQs and use the good old standard KiXtart script header
Code:

dim $rc
$rc=setoption('explicit','on')
$rc=setoption('novarsinstrings','on')