Jump to content

What is wrong with this syntax?


Recommended Posts

Guest Wowbagger
Posted

Executing this script on a 2003 server results in an error claiming that the

syntax is incorrect. What am I missing here? This script works perfectly

on an XP machine.

 

-- script begins --

 

c:

cd "c:\shared\RE Photos"

 

if not exist thumbs.db GOTO main

 

attrib -s -h thumbs.db

del thumbs.db

 

:main

if not exist #Numbered GOTO error_missing_dir

if exist 0*.* move 0*.* #Numbered /Y

if exist 1*.* move 1*.* #Numbered /Y

if exist 2*.* move 2*.* #Numbered /Y

if exist 3*.* move 3*.* #Numbered /Y

if exist 4*.* move 4*.* #Numbered /Y

if exist 5*.* move 5*.* #Numbered /Y

if exist 6*.* move 6*.* #Numbered /Y

if exist 7*.* move 7*.* #Numbered /Y

if exist 8*.* move 8*.* #Numbered /Y

if exist 9*.* move 9*.* #Numbered /Y

 

if not exist -a GOTO error_missing_dir

if exist a*.* move a*.* -a /Y

 

if not exist -b GOTO error_missing_dir

if exist b*.* move b*.* -b /Y

 

if not exist -c GOTO error_missing_dir

if exist c*.* move c*.* -c /Y

 

if not exist -d-f GOTO error_missing_dir

if exist d*.* move d*.* -d-f /Y

if exist e*.* move e*.* -d-f /Y

if exist f*.* move f*.* -d-f /Y

 

if not exist -g-i GOTO error_missing_dir

if exist g*.* move g*.* -g-i /Y

if exist h*.* move h*.* -g-i /Y

if exist i*.* move i*.* -g-i /Y

 

if not exist -j-l GOTO error_missing_dir

if exist j*.* move j*.* -j-l /Y

if exist k*.* move k*.* -j-l /Y

if exist l*.* move l*.* -j-l /Y

 

if not exist -m-n GOTO error_missing_dir

if exist m*.* move m*.* -m-n /Y

if exist n*.* move n*.* -m-n /Y

 

if not exist -o-r GOTO error_missing_dir

if exist o*.* move o*.* -o-r /Y

if exist p*.* move p*.* -o-r /Y

if exist q*.* move q*.* -o-r /Y

if exist r*.* move r*.* -o-r /Y

 

if not exist -s-t GOTO error_missing_dir

if exist s*.* move s*.* -s-t /Y

if exist t*.* move t*.* -s-t /Y

 

if not exist -u-x GOTO error_missing_dir

if exist u*.* move u*.* -u-x /Y

if exist v*.* move v*.* -u-x /Y

if exist w*.* move w*.* -u-x /Y

if exist x*.* move x*.* -u-x /Y

 

if not exist -y-z GOTO error_missing_dir

if exist y*.* move y*.* -y-z /Y

if exist z*.* move z*.* -y-z /Y

 

GOTO END

 

:error_missing_dir

@echo ERROR! Destination directory missing. Process halted.

 

:END

  • Replies 10
  • Created
  • Last Reply
Guest Pegasus \(MVP\)
Posted

Re: What is wrong with this syntax?

 

 

"Wowbagger" <Wowbagger~~> wrote in message

news:%23ZCHDr$RIHA.3916@TK2MSFTNGP02.phx.gbl...

> Executing this script on a 2003 server results in an error claiming that

> the

> syntax is incorrect. What am I missing here? This script works perfectly

> on an XP machine.

>

> -- script begins --

>

> c:

> cd "c:\shared\RE Photos"

>

> if not exist thumbs.db GOTO main

>

> attrib -s -h thumbs.db

> del thumbs.db

>

> :main

> if not exist #Numbered GOTO error_missing_dir

> if exist 0*.* move 0*.* #Numbered /Y

> if exist 1*.* move 1*.* #Numbered /Y

> if exist 2*.* move 2*.* #Numbered /Y

> if exist 3*.* move 3*.* #Numbered /Y

> if exist 4*.* move 4*.* #Numbered /Y

> if exist 5*.* move 5*.* #Numbered /Y

> if exist 6*.* move 6*.* #Numbered /Y

> if exist 7*.* move 7*.* #Numbered /Y

> if exist 8*.* move 8*.* #Numbered /Y

> if exist 9*.* move 9*.* #Numbered /Y

>

> if not exist -a GOTO error_missing_dir

> if exist a*.* move a*.* -a /Y

>

> if not exist -b GOTO error_missing_dir

> if exist b*.* move b*.* -b /Y

>

> if not exist -c GOTO error_missing_dir

> if exist c*.* move c*.* -c /Y

>

> if not exist -d-f GOTO error_missing_dir

> if exist d*.* move d*.* -d-f /Y

> if exist e*.* move e*.* -d-f /Y

> if exist f*.* move f*.* -d-f /Y

>

> if not exist -g-i GOTO error_missing_dir

> if exist g*.* move g*.* -g-i /Y

> if exist h*.* move h*.* -g-i /Y

> if exist i*.* move i*.* -g-i /Y

>

> if not exist -j-l GOTO error_missing_dir

> if exist j*.* move j*.* -j-l /Y

> if exist k*.* move k*.* -j-l /Y

> if exist l*.* move l*.* -j-l /Y

>

> if not exist -m-n GOTO error_missing_dir

> if exist m*.* move m*.* -m-n /Y

> if exist n*.* move n*.* -m-n /Y

>

> if not exist -o-r GOTO error_missing_dir

> if exist o*.* move o*.* -o-r /Y

> if exist p*.* move p*.* -o-r /Y

> if exist q*.* move q*.* -o-r /Y

> if exist r*.* move r*.* -o-r /Y

>

> if not exist -s-t GOTO error_missing_dir

> if exist s*.* move s*.* -s-t /Y

> if exist t*.* move t*.* -s-t /Y

>

> if not exist -u-x GOTO error_missing_dir

> if exist u*.* move u*.* -u-x /Y

> if exist v*.* move v*.* -u-x /Y

> if exist w*.* move w*.* -u-x /Y

> if exist x*.* move x*.* -u-x /Y

>

> if not exist -y-z GOTO error_missing_dir

> if exist y*.* move y*.* -y-z /Y

> if exist z*.* move z*.* -y-z /Y

>

> GOTO END

>

> :error_missing_dir

> @echo ERROR! Destination directory missing. Process halted.

>

> :END

 

You posted 75 lines of code for respondents to analyse. If you

start your batch file with "@echo on" then you will see the

offending line on the screen, thus saving us the labour of

analysing each and every line of your code. Please post that

line so that we can take it from there.

Guest Wowbagger
Posted

Re: What is wrong with this syntax?

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:eKvolOBSIHA.3516@TK2MSFTNGP02.phx.gbl...

> You posted 75 lines of code for respondents to analyse. If you

> start your batch file with "@echo on" then you will see the

> offending line on the screen, thus saving us the labour of

> analysing each and every line of your code. Please post that

> line so that we can take it from there.

 

The execution of every one of the move commands results in the same error:

> if exist g*.* move g*.* -g-i /Y

The syntax of the command is incorrect.

Guest Pegasus \(MVP\)
Posted

Re: What is wrong with this syntax?

 

 

"Wowbagger" <Wowbagger~~> wrote in message

news:%23HdjSJNSIHA.5104@TK2MSFTNGP05.phx.gbl...

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:eKvolOBSIHA.3516@TK2MSFTNGP02.phx.gbl...

>

>> You posted 75 lines of code for respondents to analyse. If you

>> start your batch file with "@echo on" then you will see the

>> offending line on the screen, thus saving us the labour of

>> analysing each and every line of your code. Please post that

>> line so that we can take it from there.

>

> The execution of every one of the move commands results in the same error:

>

>> if exist g*.* move g*.* -g-i /Y

> The syntax of the command is incorrect.

>

>

 

A small amount of experimentation reveals that the position

of the /Y switch is critical under Win2003: it must be placed

after the "move" command.

Guest Wowbagger
Posted

Re: What is wrong with this syntax?

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:OmZLADOSIHA.3940@TK2MSFTNGP05.phx.gbl...

> A small amount of experimentation reveals that the position

> of the /Y switch is critical under Win2003: it must be placed

> after the "move" command.

 

Thank you. This solves most of the problem, but there is still an oddity:

 

Some of the commands work, others will not. For example,

 

C:\Shared\RE Photos>if exist o*.* move /Y o*.* .\-o-r

C:\Shared\RE Photos>if exist p*.* move /Y p*.* .\-o-r

C:\Shared\RE Photos>if exist q*.* move /Y q*.* .\-o-r

C:\Shared\RE Photos>if exist y*.* move /Y y*.* .\-y-z

 

All work perfectly, but

 

C:\Shared\RE Photos>if exist r*.* move /Y r*.* .\-o-r

The filename, directory name, or volume label syntax is incorrect.

 

C:\Shared\RE Photos>if exist z*.* move /Y z*.* .\-y-z

The filename, directory name, or volume label syntax is incorrect.

 

What is special about r*.* and z*.*?

Guest Pegasus \(MVP\)
Posted

Re: What is wrong with this syntax?

 

 

"Wowbagger" <Wowbagger~~> wrote in message

news:e4AAcKOSIHA.3516@TK2MSFTNGP02.phx.gbl...

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:OmZLADOSIHA.3940@TK2MSFTNGP05.phx.gbl...

>

>> A small amount of experimentation reveals that the position

>> of the /Y switch is critical under Win2003: it must be placed

>> after the "move" command.

>

> Thank you. This solves most of the problem, but there is still an oddity:

>

> Some of the commands work, others will not. For example,

>

> C:\Shared\RE Photos>if exist o*.* move /Y o*.* .\-o-r

> C:\Shared\RE Photos>if exist p*.* move /Y p*.* .\-o-r

> C:\Shared\RE Photos>if exist q*.* move /Y q*.* .\-o-r

> C:\Shared\RE Photos>if exist y*.* move /Y y*.* .\-y-z

>

> All work perfectly, but

>

> C:\Shared\RE Photos>if exist r*.* move /Y r*.* .\-o-r

> The filename, directory name, or volume label syntax is incorrect.

>

> C:\Shared\RE Photos>if exist z*.* move /Y z*.* .\-y-z

> The filename, directory name, or volume label syntax is incorrect.

>

> What is special about r*.* and z*.*?

>

>

 

The command

 

if exist r*.* move /Y r*.* .\-o-r

 

works perfectly well on my Win2003 machine, provided that

there is an "-o-r" folder hanging off the current folder. By the

way, what's the dot doing in front of the backslash? If "-o-r"

is a root directory then the command should read

 

if exist r*.* move /Y r*.* \-o-r

 

and if if it hangs off the current directory then it should be

 

if exist r*.* move /Y r*.* -o-r

 

Having the dot there makes no sense.

Guest Wowbagger
Posted

Re: What is wrong with this syntax?

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:%23oSaZyRSIHA.2000@TK2MSFTNGP05.phx.gbl...

>> C:\Shared\RE Photos>if exist q*.* move /Y q*.* .\-o-r

>> C:\Shared\RE Photos>if exist r*.* move /Y r*.* .\-o-r

> if exist r*.* move /Y r*.* .\-o-r

>

> works perfectly well on my Win2003 machine, provided that

> there is an "-o-r" folder hanging off the current folder.

 

That's the odd part - the q*.* files move into the -o-r folder without any

difficulty but trying to move the r*.* files generates the error.

> By the way, what's the dot doing in front of the backslash?

 

An artifact from my troubleshooting attempts. By using the .\ I was

explicitly declaring that the destination folder is located off of the

current folder, just in case the system was doing something even stranger

than what it is.

Guest Pegasus \(MVP\)
Posted

Re: What is wrong with this syntax?

 

 

"Wowbagger" <Wowbagger~~> wrote in message

news:uYOszDVSIHA.484@TK2MSFTNGP06.phx.gbl...

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> news:%23oSaZyRSIHA.2000@TK2MSFTNGP05.phx.gbl...

>>> C:\Shared\RE Photos>if exist q*.* move /Y q*.* .\-o-r

>

>>> C:\Shared\RE Photos>if exist r*.* move /Y r*.* .\-o-r

>

>> if exist r*.* move /Y r*.* .\-o-r

>>

>> works perfectly well on my Win2003 machine, provided that

>> there is an "-o-r" folder hanging off the current folder.

>

> That's the odd part - the q*.* files move into the -o-r folder without any

> difficulty but trying to move the r*.* files generates the error.

>

>> By the way, what's the dot doing in front of the backslash?

>

> An artifact from my troubleshooting attempts. By using the .\ I was

> explicitly declaring that the destination folder is located off of the

> current folder, just in case the system was doing something even stranger

> than what it is.

>

 

I suspect you have something else starting with the letter "r".

 

Let's keep things simple: To move files from the current

folder to the "-o-r" folder, it is sufficient to write

 

if exist r*.* move /Y r*.* -o-r

 

Adding extra dots and slashes only confuses the issue.

Guest Wowbagger
Posted

Re: What is wrong with this syntax?

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

> I suspect you have something else starting with the letter "r".

 

This was exactly it, thank you.

Guest Pegasus \(MVP\)
Posted

Re: What is wrong with this syntax?

 

 

"Wowbagger" <Wowbagger~~> wrote in message

news:u18aCuXSIHA.5524@TK2MSFTNGP05.phx.gbl...

> "Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

>

>> I suspect you have something else starting with the letter "r".

>

> This was exactly it, thank you.

>

 

You're welcome.

 

If it is your job to maintain servers then you might find it

advantageous to be a little inquisitive. Look at your problems

from all sides, try this and that, and in many cases you will find

an easy solution. This is precisely what I did with our initial

problem regarding the syntax error: I started playing with your

command until I found that it was sensitive to the order of the

parameters. Same with the second problem: Since it made no

sense that Windows would treat "r" files differently from "s" or

"a" files, there had to be something unexpected on your disk

that started with "r".

Guest Wowbagger
Posted

Re: What is wrong with this syntax?

 

"Pegasus (MVP)" <I.can@fly.com.oz> wrote in message

news:%23Ak4RzXSIHA.4152@TK2MSFTNGP05.phx.gbl...

> If it is your job to maintain servers then you might find it

> advantageous to be a little inquisitive.

 

What was driving me nuts was that the syntax was working perfectly as is if

I ran it from an XP box, but wasn't working when I executed it from the

server. I never would have suspected in a million years that they would

make a change like that.


×
×
  • Create New...