jeff_eisenberg
(Fresh Scripter)
2009-04-18 02:23 AM
Move Command

This is kind of a dumb one but for some reason I can't get this move command to work. Is there something wrong with this syntax?

MOVE "\\SF1-FILE-1\USERS\@USERID\My Music\" "%SystemDrive%\My Music\" /c/h/r/s


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-18 04:07 AM
Re: Move Command

If you have NoMacrosInStrings active, that won't work.. Try this:
 Code:
$Src = '"\\SF1-FILE-1\USERS\' + @USERID + '\My Music\"'
$Dst = '"%SystemDrive%\My Music\"'
'Moving ' $Src ' to ' $Dst ? ; for debugging
Move $Src $Dst /c /h /r /s   ; note spaces

Glenn


jeff_eisenberg
(Fresh Scripter)
2009-04-21 08:33 PM
Re: Move Command

NoMacrosInStrings is set to OFF as the default setting

-The COPY command will work and will copy the "My Music" directory
-Either of the MOVE commands above will not move the "My Music" directory.
-I can rename or delete the "My Music" director so I don't think it's a rights issue.
-Could there be something else with the syntax??

Thanks, Jeff


jeff_eisenberg
(Fresh Scripter)
2009-04-21 08:37 PM
Re: Move Command

Also, the debug seems to show the correct syntax:

Moving \\SF1-FILE-1\USERS\username\My Music\ to C:\My Music\

Jeff


Gargoyle
(MM club member)
2009-04-21 09:05 PM
Re: Move Command

Add this to your code...
 Code:
$Src = '\\SF1-FILE-1\USERS\' + @USERID + '\My Music\'
$Dst = '"%SystemDrive%\My Music\'
'Moving ' $Src ' to ' $Dst ? ; for debugging
Move $Src $Dst /c /h /r /s   ; note spaces
'Return code was ' @error ' this means ' @serror ?


jeff_eisenberg
(Fresh Scripter)
2009-04-21 09:36 PM
Re: Move Command

Thanks:

Moving \\SF1-FILE-1\USERS\username\My Music\ to "C:\My Music\
Return code was 87 this means The parameter is incorrect

Could it have something to do with the placement of quotes?


Gargoyle
(MM club member)
2009-04-22 02:06 AM
Re: Move Command

Just noticed that there are missing quotes.


$Src = '"\\SF1-FILE-1\USERS\"' + @USERID + '"\My Music\"'
$Dst = '"%SystemDrive%\My Music\"'


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-22 02:39 AM
Re: Move Command

I think you went from missing quotes to weird-extra quotes.. ;\)

You need a double-quote AFTER the FIRST single-quote and BEFORE the LAST single-quote, but none in the middle, so that your result is something like
"\\sf1-file-1\users\JoeUser\My Music", not "\\sf1-file-1\users\"JoeUser"\My Music".

Your debug message should show the double-quotes at each end of the string, with no double-quotes in the middle. An error-87 is an Invalid Parameter - probably due to the inconsistent quoting.

Glenn


jeff_eisenberg
(Fresh Scripter)
2009-04-22 05:13 AM
Re: Move Command

Actually, I had corrected that and got a different error:

My corrected syntax now is:
 Code:
$Src = '"\\JA-FILE1\USERS\' + @USERID + '\My Music\"'
$Dst = '"%SystemDrive%\My Music\"'
Move $Src $Dst /c /h /r /s


And the error is get now is... and this is verbatum:
"Return code was 123 means tax is incorrect.ectory name, or volume label syn"

what does this mean, and could you tell me where I reference the codes?

Thanks again for your help.

Jeff


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-22 05:45 AM
Re: Move Command

Looks like your messages are overwriting on your screen - add
 Code:
$ = SetOption('WrapAtEOL', 'On')
to the beginning of your script to have it display across multiple lines - it might make more sense.

You can find most error codes on the MSDN web site, and some other web sites dedicated to helping decipher the codes.

If you print your vars -
 Code:
 'Move ' $Src ' to ' $Dst ?
does the command look correct? Quotes in the right place? If so, copy the text off the screen and paste it into a .kix file to test - as is - and see what you get.

If that errors as well, try
 Code:
If Exist($Src) 'Got source!' ? EndIf
If Exist($Dst) 'Got destination!' ? EndIf
to see if Kix can actually verify the paths.

Glenn


jeff_eisenberg
(Fresh Scripter)
2009-04-23 07:17 PM
Re: Move Command

OK...

The MOVE command works fine if it uses drive letters. But once I change it to UNC it fails. I think the problem centers around UNC.

I think this syntax is fine. Printing the vars looks correct with quotes.
$Src = '"\\JA-FILE1\USERS\' + @USERID + '\My Music\"'

But if I copy it directly to kix, I get an error. Even if I put a very simple path like "\\Server\share\folder\", I get the same error:

"Return code was 123 this means The filename, directory name, or volume label syntax is incorrect"

Is there some special syntax for UNC? I've never had an issue with UNC vs drive letter specifications.

Thanks,
JEff


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-23 11:29 PM
Re: Move Command

I'll try to reproduce it when I get to the lab..

Glenn


NTDOCAdministrator
(KiX Master)
2009-04-23 11:59 PM
Re: Move Command

UNC does not support LONG file names even when using quotes. You must use the SHORT name for the path.

jeff_eisenberg
(Fresh Scripter)
2009-04-24 12:43 AM
Re: Move Command

But wouldn't this be a "short" filename:

"\\Server\share\folder\"

The exact path was:
"\\JA-FILE1\External\Test"

And I still got the error. Do you mean spaces by long?

Jeff.


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-24 01:20 AM
Re: Move Command

Closest match I could come up with..
 Code:
$S = 'c:\temp\test.txt'
$D = '\\server\dev\misc\' + @USERID + '\My Test\'
; make sure folder exists..
MD $D
; move the file
Move $S $D
@SERROR ?
Result was success, file was moved. Destination path contained userID value and spaces (My Test).

Hmm - note that I DO NOT have embedded quotes in that test... When I put the quotes in and try again with test2.txt, I get:
 Code:
G0PW01 - C:\temp>x.kix
Move c:\temp\test2.txt "\\g0smp00\dev\misc\gbarnas\My Test\"
The filename, directory name, or volume label syntax is incorrect.

Ditch the quotes!

Glenn


jeff_eisenberg
(Fresh Scripter)
2009-04-24 07:31 PM
Re: Move Command

Thanks. That works on my end as well. But when I try to move the entire folder "My Music" located on a UNC to the local drive, it does not work.

I'm trying to move \\Server\Share\My Test to C:\My Test

It seems that moving a file works but not an entire folder even with the switch /s even if I create the folder in the destination (MD) wehn it does not exist.

However, "COPY" does work. So I tried to run the COPY command followed up with an "RD /s" which did not work. Perhaps the problem with the MOVE command has to do with removing the directory when it's finished?

Jeff.


jeff_eisenberg
(Fresh Scripter)
2009-04-24 11:42 PM
Re: Move Command

I think I can do the following. Could you just help me with proper quotage around the var in the second line. How would you break out of the shell command to specify the $Src var?

COPY $Src $Dst /s
Shell "%ComSpec% /c RD $Src /S /Q"

Jeff.


Glenn BarnasAdministrator
(KiX Supporter)
2009-04-25 01:19 AM
Re: Move Command

That should be
 Code:
Shell '%ComSpec% /c RD "' + $Src + '"/S /Q'
Here the quotes are used to enclose the $Src content in case it has spaces.

Glenn