Technology Questions

Go Back   Technology Questions > Software Questions > Operating System Questions > Windows XP

Windows XP Discuss the Microsoft Windows XP Operating System



Reply
 
LinkBack Thread Tools
  #1  
Old 02-01-2008, 09:20 AM
Danger
Newsgroup Contributor
 
Posts: n/a
Batch file works in command line but not as a batch

This batch file is a simple rename of a file folder
I can run it on the command line and it works, In a batch file it can not
find the file name.

the code
_____________

C:
cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
Motion\BlackBerry
IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
PAUSE
ren intellisync intellisync-old
pause

___________________

the result


C:\Documents and Settings\Administrator\Application Data\Research In
Motion\Blac
kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
SUCESS )

SUCESS

C:\Documents and Settings\Administrator\Application Data\Research In
Motion\Blac
kBerry>PAUSE
Press any key to continue . . .

C:\Documents and Settings\Administrator\Application Data\Research In
Motion\Blac
kBerry>ren intellisync intellisync-old
The system cannot find the file specified.

C:\Documents and Settings\Administrator\Application Data\Research In
Motion\Blac
kBerry>pause
Press any key to continue . . .

_____________________________________

the file folder with the correct name is in the correct dir

Thank you in advance,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

 
Old 02-01-2008, 09:20 AM
  #2  
Old 02-01-2008, 10:00 AM
Bob I
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch

You need quotes around path names with spaces.

Danger wrote:

> This batch file is a simple rename of a file folder
> I can run it on the command line and it works, In a batch file it can not
> find the file name.
>
> the code
> _____________
>
> C:
> cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
> Motion\BlackBerry
> IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> PAUSE
> ren intellisync intellisync-old
> pause
>
> ___________________
>
> the result
>
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
> SUCESS )
>
> SUCESS
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>PAUSE
> Press any key to continue . . .
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>ren intellisync intellisync-old
> The system cannot find the file specified.
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>pause
> Press any key to continue . . .
>
> _____________________________________
>
> the file folder with the correct name is in the correct dir
>
> Thank you in advance,


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3  
Old 02-01-2008, 10:30 AM
Danger
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch

Sorry The change to directory works fine. you can see that below in the
output example. Thanks however.

"Bob I" wrote:

> You need quotes around path names with spaces.
>
> Danger wrote:
>
> > This batch file is a simple rename of a file folder
> > I can run it on the command line and it works, In a batch file it can not
> > find the file name.
> >
> > the code
> > _____________
> >
> > C:
> > cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
> > Motion\BlackBerry
> > IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> > PAUSE
> > ren intellisync intellisync-old
> > pause
> >
> > ___________________
> >
> > the result
> >
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
> > SUCESS )
> >
> > SUCESS
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>PAUSE
> > Press any key to continue . . .
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>ren intellisync intellisync-old
> > The system cannot find the file specified.
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>pause
> > Press any key to continue . . .
> >
> > _____________________________________
> >
> > the file folder with the correct name is in the correct dir
> >
> > Thank you in advance,

>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4  
Old 02-01-2008, 12:30 PM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch


"Danger" <Danger@discussions.microsoft.com> wrote in message
news:4069A1AB-B395-4E74-B411-598FCA86E1AA@microsoft.com...
> This batch file is a simple rename of a file folder
> I can run it on the command line and it works, In a batch file it can not
> find the file name.
>
> the code
> _____________
>
> C:
> cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
> Motion\BlackBerry
> IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> PAUSE
> ren intellisync intellisync-old
> pause
>
> ___________________
>
> the result
>
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
> SUCESS )
>
> SUCESS
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>PAUSE
> Press any key to continue . . .
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>ren intellisync intellisync-old
> The system cannot find the file specified.
>
> C:\Documents and Settings\Administrator\Application Data\Research In
> Motion\Blac
> kBerry>pause
> Press any key to continue . . .
>
> _____________________________________
>
> the file folder with the correct name is in the correct dir
>
> Thank you in advance,


Your batch file tests for the existence of "intellisync.old". It does
not test for the existence of "intellisync", hence the attempt to
rename this folder will fail if the folder does not exist. Nothing
magic there.

About the quotes, missing or otherwise: You ***should***
always surround file/folder names with quotes if they could
contain embedded spaces. There is one exception which
you have found out yourself: The "CD" command does not
require quotes (but it does not object to them either).


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5  
Old 02-01-2008, 02:00 PM
Danger
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch



"Pegasus (MVP)" wrote:

>
> "Danger" <Danger@discussions.microsoft.com> wrote in message
> news:4069A1AB-B395-4E74-B411-598FCA86E1AA@microsoft.com...
> > This batch file is a simple rename of a file folder
> > I can run it on the command line and it works, In a batch file it can not
> > find the file name.
> >
> > the code
> > _____________
> >
> > C:
> > cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
> > Motion\BlackBerry
> > IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> > PAUSE
> > ren intellisync intellisync-old
> > pause
> >
> > ___________________
> >
> > the result
> >
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
> > SUCESS )
> >
> > SUCESS
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>PAUSE
> > Press any key to continue . . .
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>ren intellisync intellisync-old
> > The system cannot find the file specified.
> >
> > C:\Documents and Settings\Administrator\Application Data\Research In
> > Motion\Blac
> > kBerry>pause
> > Press any key to continue . . .
> >
> > _____________________________________
> >
> > the file folder with the correct name is in the correct dir
> >
> > Thank you in advance,

>
> Your batch file tests for the existence of "intellisync.old". It does
> not test for the existence of "intellisync", hence the attempt to
> rename this folder will fail if the folder does not exist. Nothing
> magic there.
>
> About the quotes, missing or otherwise: You ***should***
> always surround file/folder names with quotes if they could
> contain embedded spaces. There is one exception which
> you have found out yourself: The "CD" command does not
> require quotes (but it does not object to them either).
>

In this case "intellisync-old" a folder does exist however it isnt being
deleted at all
hence the sucess message.

section the "intellisync" folder (automajikly created) is assumed correctly
to be there but it cant rename.

>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #6  
Old 02-01-2008, 02:30 PM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch


"Danger" <Danger@discussions.microsoft.com> wrote in message
news:AE5C946C-603A-44A2-8B98-F2B598594D4D@microsoft.com...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "Danger" <Danger@discussions.microsoft.com> wrote in message
>> news:4069A1AB-B395-4E74-B411-598FCA86E1AA@microsoft.com...
>> > This batch file is a simple rename of a file folder
>> > I can run it on the command line and it works, In a batch file it can
>> > not
>> > find the file name.
>> >
>> > the code
>> > _____________
>> >
>> > C:
>> > cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
>> > Motion\BlackBerry
>> > IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
>> > PAUSE
>> > ren intellisync intellisync-old
>> > pause
>> >
>> > ___________________
>> >
>> > the result
>> >
>> >
>> > C:\Documents and Settings\Administrator\Application Data\Research In
>> > Motion\Blac
>> > kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
>> > SUCESS )
>> >
>> > SUCESS
>> >
>> > C:\Documents and Settings\Administrator\Application Data\Research In
>> > Motion\Blac
>> > kBerry>PAUSE
>> > Press any key to continue . . .
>> >
>> > C:\Documents and Settings\Administrator\Application Data\Research In
>> > Motion\Blac
>> > kBerry>ren intellisync intellisync-old
>> > The system cannot find the file specified.
>> >
>> > C:\Documents and Settings\Administrator\Application Data\Research In
>> > Motion\Blac
>> > kBerry>pause
>> > Press any key to continue . . .
>> >
>> > _____________________________________
>> >
>> > the file folder with the correct name is in the correct dir
>> >
>> > Thank you in advance,

>>
>> Your batch file tests for the existence of "intellisync.old". It does
>> not test for the existence of "intellisync", hence the attempt to
>> rename this folder will fail if the folder does not exist. Nothing
>> magic there.
>>
>> About the quotes, missing or otherwise: You ***should***
>> always surround file/folder names with quotes if they could
>> contain embedded spaces. There is one exception which
>> you have found out yourself: The "CD" command does not
>> require quotes (but it does not object to them either).
>>

> In this case "intellisync-old" a folder does exist however it isnt being
> deleted at all
> hence the sucess message.
>
> section the "intellisync" folder (automajikly created) is assumed
> correctly
> to be there but it cant rename.
>


Let's do some real tests:
@echo off
cd /d "%UserProfile%\Application Data\Research In Motion\BlackBerry"
IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
dir intelli*.*
pause
if exist intellisync ren intellisync intellisync-old
pause

You will find that this batch file works as well as if you executed
the same commands from a Command Prompt.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #7  
Old 02-05-2008, 07:50 AM
Danger
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch

Works like a charm wonder why the other did not?
thank you

"Pegasus (MVP)" wrote:

>
> "Danger" <Danger@discussions.microsoft.com> wrote in message
> news:AE5C946C-603A-44A2-8B98-F2B598594D4D@microsoft.com...
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "Danger" <Danger@discussions.microsoft.com> wrote in message
> >> news:4069A1AB-B395-4E74-B411-598FCA86E1AA@microsoft.com...
> >> > This batch file is a simple rename of a file folder
> >> > I can run it on the command line and it works, In a batch file it can
> >> > not
> >> > find the file name.
> >> >
> >> > the code
> >> > _____________
> >> >
> >> > C:
> >> > cd C:\Documents and Settings\%USERNAME%\Application Data\Research In
> >> > Motion\BlackBerry
> >> > IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> >> > PAUSE
> >> > ren intellisync intellisync-old
> >> > pause
> >> >
> >> > ___________________
> >> >
> >> > the result
> >> >
> >> >
> >> > C:\Documents and Settings\Administrator\Application Data\Research In
> >> > Motion\Blac
> >> > kBerry>IF Exist intellisync-old (rd /s /q intellisync-old ) ELSE (ECHO
> >> > SUCESS )
> >> >
> >> > SUCESS
> >> >
> >> > C:\Documents and Settings\Administrator\Application Data\Research In
> >> > Motion\Blac
> >> > kBerry>PAUSE
> >> > Press any key to continue . . .
> >> >
> >> > C:\Documents and Settings\Administrator\Application Data\Research In
> >> > Motion\Blac
> >> > kBerry>ren intellisync intellisync-old
> >> > The system cannot find the file specified.
> >> >
> >> > C:\Documents and Settings\Administrator\Application Data\Research In
> >> > Motion\Blac
> >> > kBerry>pause
> >> > Press any key to continue . . .
> >> >
> >> > _____________________________________
> >> >
> >> > the file folder with the correct name is in the correct dir
> >> >
> >> > Thank you in advance,
> >>
> >> Your batch file tests for the existence of "intellisync.old". It does
> >> not test for the existence of "intellisync", hence the attempt to
> >> rename this folder will fail if the folder does not exist. Nothing
> >> magic there.
> >>
> >> About the quotes, missing or otherwise: You ***should***
> >> always surround file/folder names with quotes if they could
> >> contain embedded spaces. There is one exception which
> >> you have found out yourself: The "CD" command does not
> >> require quotes (but it does not object to them either).
> >>

> > In this case "intellisync-old" a folder does exist however it isnt being
> > deleted at all
> > hence the sucess message.
> >
> > section the "intellisync" folder (automajikly created) is assumed
> > correctly
> > to be there but it cant rename.
> >

>
> Let's do some real tests:
> @echo off
> cd /d "%UserProfile%\Application Data\Research In Motion\BlackBerry"
> IF Exist intellisync-old (rd /s /q intellisync-old) ELSE (ECHO SUCESS)
> dir intelli*.*
> pause
> if exist intellisync ren intellisync intellisync-old
> pause
>
> You will find that this batch file works as well as if you executed
> the same commands from a Command Prompt.
>
>
>

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #8  
Old 02-05-2008, 08:00 AM
Pegasus \(MVP\)
Newsgroup Contributor
 
Posts: n/a
Re: Batch file works in command line but not as a batch


"Danger" <Danger@discussions.microsoft.com> wrote in message
news:F14AF84E-5A9A-49D7-81DF-88B04E8D3F19@microsoft.com...
> Works like a charm wonder why the other did not?
> thank you
>


I suspect there was a flaw in your logic.


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How To Execute Batch File Line By Line RitaG Windows XP 4 03-22-2007 06:46 AM
Fast User Switching via Command Line or Batch File? Woody45 Windows Vista 1 03-17-2007 11:00 AM
FOR Command in a batch file pestrue@gmail.com Windows XP 1 02-16-2007 09:17 AM
Save batch window msgs to a file from the batch prog Stephen Rainey Windows XP 3 01-09-2007 05:15 PM
COPY command in a batch file Ken W Windows XP 16 01-04-2007 01:40 AM


New To Technology Questions? Do You Need Help with Your Computer or Device? Do You Need Help with this site?

All times are GMT -8. The time now is 01:08 AM.


2003 - 2010 All Rights Reserved. Technology Questions

Search Engine Friendly URLs by vBSEO 3.3.0