Page 1 of 1 1
Topic Options
#124053 - 2004-07-28 02:13 PM SHELL + ROBOCOPY + DIR with spacebar problem
Henry Offline
Fresh Scripter

Registered: 2004-07-27
Posts: 6
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

Top
#124054 - 2004-07-28 02:17 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
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


Top
#124055 - 2004-07-28 02:35 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Henry Offline
Fresh Scripter

Registered: 2004-07-27
Posts: 6
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.
******************************************************************

Top
#124056 - 2004-07-28 02:45 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
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

_________________________



Top
#124057 - 2004-07-28 02:56 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
ja, looks like maybe you got some mis-matched quotes somewhere. at least post the section where your creating these $vars.
Top
#124058 - 2004-07-28 03:12 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Henry Offline
Fresh Scripter

Registered: 2004-07-27
Posts: 6
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"

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

Top
#124059 - 2004-07-28 04:23 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Stanley Offline
Starting to like KiXtart

Registered: 2004-06-03
Posts: 130
Loc: Upstate NY, USA
$source = "c:\"+'"Documents And Settings"'+"\User.old\"+'"My Documents"'+"\"
$destination = "c:\"+'"Documents And Settings"'+"\User.new\"+'"My Documents"'+"\"

Would this work?
_________________________
Taxation WITH representation isn't so hot, either!

Top
#124060 - 2004-07-28 04:34 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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"\
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124061 - 2004-07-28 04:37 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
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
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124062 - 2004-07-28 06:09 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Chris_Wood Offline
Lurker

Registered: 2004-07-28
Posts: 4
Loc: Indianapolis
$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

Top
#124063 - 2004-07-28 07:03 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Single outside, double inside is a lot easier than CHR(34) and vars in strings are evil!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124064 - 2004-07-28 08:10 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
Henry Offline
Fresh Scripter

Registered: 2004-07-27
Posts: 6
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'
*************************

Top
#124065 - 2004-07-28 08:30 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
Vars in strings are still EVIL!
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124066 - 2004-07-28 09:55 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
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<><
_________________________
Every day is a school day

Top
#124067 - 2004-07-28 09:57 PM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
acmp Offline
Getting the hang of it

Registered: 2004-07-02
Posts: 69
Loc: Bingham, Nottinghamshire, Engl...
What's the big problem with vars in strings?

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

acmp<><
_________________________
Every day is a school day

Top
#124068 - 2004-07-29 12:42 AM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2125
Loc: Tulsa, OK
*************************
; 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.

Top
#124069 - 2004-07-29 12:47 AM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
That would work too, and no evil vars in strings in that example.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#124070 - 2004-07-29 04:11 AM Re: SHELL + ROBOCOPY + DIR with spacebar problem resolved
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
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')


_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Glenn Barnas, NTDOC, Arend_, Jochen, Radimus, Allen, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Allen) and 466 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.081 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org