PC Review


Reply
Thread Tools Rate Thread

Batch File Problem

 
 
Sid Elbow
Guest
Posts: n/a
 
      3rd Mar 2010
I'm trying to run the following batch file:


@echo off

rem ***Set cbreak parms here, after the equals sign ***
set cbreakparms=-b60 -d20 -s60

:again
if "%1"=="" goto end
mkdir "%~dp1cbreak"
cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
shift
goto again
:end

It fails with the message:

" 'cbreak' is not recognized as an internal or external command,
operable program or batch file"

..... yet the program cbreak.exe does exist and is in the same directory
as the batch file. If I edit the batch file and give the full path to
cbreak the batch will run correctly - I don't particularly want to do
that since it will make the batch file location-dependent.

Why does it not find cbreak in it's own directory?
 
Reply With Quote
 
 
 
 
Pegasus [MVP]
Guest
Posts: n/a
 
      3rd Mar 2010


"Sid Elbow" <(E-Mail Removed)> wrote in message
news:4b8ee111$0$14756$(E-Mail Removed)...
> I'm trying to run the following batch file:
>
>
> @echo off
>
> rem ***Set cbreak parms here, after the equals sign ***
> set cbreakparms=-b60 -d20 -s60
>
> :again
> if "%1"=="" goto end
> mkdir "%~dp1cbreak"
> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
> shift
> goto again
> :end
>
> It fails with the message:
>
> " 'cbreak' is not recognized as an internal or external command, operable
> program or batch file"
>
> .... yet the program cbreak.exe does exist and is in the same directory as
> the batch file. If I edit the batch file and give the full path to cbreak
> the batch will run correctly - I don't particularly want to do that since
> it will make the batch file location-dependent.
>
> Why does it not find cbreak in it's own directory?


I suspect that the above is not the batch file that generates the error
message. I also can't quite see how the line
cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
could work. AFAIR, the code you use requires a "for %%a in" construct.

I would set "echo on" to see which line generates the error.

 
Reply With Quote
 
Sid Elbow
Guest
Posts: n/a
 
      4th Mar 2010
Pegasus [MVP] wrote:
>
>
> "Sid Elbow" <(E-Mail Removed)> wrote in message
> news:4b8ee111$0$14756$(E-Mail Removed)...
>> I'm trying to run the following batch file:
>>
>>
>> @echo off
>>
>> rem ***Set cbreak parms here, after the equals sign ***
>> set cbreakparms=-b60 -d20 -s60
>>
>> :again
>> if "%1"=="" goto end
>> mkdir "%~dp1cbreak"
>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>> shift
>> goto again
>> :end
>>
>> It fails with the message:
>>
>> " 'cbreak' is not recognized as an internal or external command,
>> operable program or batch file"
>>
>> .... yet the program cbreak.exe does exist and is in the same
>> directory as the batch file. If I edit the batch file and give the
>> full path to cbreak the batch will run correctly - I don't
>> particularly want to do that since it will make the batch file
>> location-dependent.
>>
>> Why does it not find cbreak in it's own directory?

>
> I suspect that the above is not the batch file that generates the error
> message. I also can't quite see how the line
> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
> could work. AFAIR, the code you use requires a "for %%a in" construct.
>
> I would set "echo on" to see which line generates the error.



Thanks for the response, Pegasus.

I did as you suggested and turned echo on. It is indeed the line:

cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%

which generates the error.


Some background .... the program cbreak.exe is used (with some
command-line parameters) to remove commercials from video files. The
above batch file is used by drag-and-drop'ing a number of video files on
to the batch file. In my (somewhat limited) understanding, this sets the
batch file parameters (%1, %2, %3 etc) to the names of those files. The
"shift" command is then used to present each file in turn to the
cbreak.exe program along with an output directory and some control
parameters.

In fact, that part of the batch file seems to work if I put in the full
path for cbreak.exe, but I don't understand why that is necessary (since
all involved files are in the same directory).
 
Reply With Quote
 
me@tadyatam.invalid
Guest
Posts: n/a
 
      4th Mar 2010
Sid Elbow <(E-Mail Removed)> wrote in
news:4b8f0657$0$24276$(E-Mail Removed):

> Pegasus [MVP] wrote:
>>
>>
>> "Sid Elbow" <(E-Mail Removed)> wrote in message
>> news:4b8ee111$0$14756$(E-Mail Removed)...
>>> I'm trying to run the following batch file:
>>>
>>>
>>> @echo off
>>>
>>> rem ***Set cbreak parms here, after the equals sign ***
>>> set cbreakparms=-b60 -d20 -s60
>>>
>>> :again
>>> if "%1"=="" goto end
>>> mkdir "%~dp1cbreak"
>>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>>> shift
>>> goto again
>>> :end
>>>
>>> It fails with the message:
>>>
>>> " 'cbreak' is not recognized as an internal or external
>>> command, operable program or batch file"
>>>
>>> .... yet the program cbreak.exe does exist and is in the
>>> same directory as the batch file. If I edit the batch
>>> file and give the full path to cbreak the batch will run
>>> correctly - I don't particularly want to do that since it
>>> will make the batch file location-dependent.
>>>
>>> Why does it not find cbreak in it's own directory?

>>
>> I suspect that the above is not the batch file that
>> generates the error message. I also can't quite see how
>> the line cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>> could work. AFAIR, the code you use requires a "for %%a
>> in" construct.
>>
>> I would set "echo on" to see which line generates the
>> error.

>
>
> Thanks for the response, Pegasus.
>
> I did as you suggested and turned echo on. It is indeed the
> line:
>
> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>
> which generates the error.
>
>
> Some background .... the program cbreak.exe is used (with
> some command-line parameters) to remove commercials from
> video files. The above batch file is used by
> drag-and-drop'ing a number of video files on to the batch
> file. In my (somewhat limited) understanding, this sets the
> batch file parameters (%1, %2, %3 etc) to the names of
> those files. The "shift" command is then used to present
> each file in turn to the cbreak.exe program along with an
> output directory and some control parameters.
>
> In fact, that part of the batch file seems to work if I put
> in the full path for cbreak.exe, but I don't understand why
> that is necessary (since all involved files are in the same
> directory).


Sid,

Suggestion: add justt before "cbreak" a la
cd
pause

You need full path to the .exe because the path is relative to
current dir, not to whatever is passed to the .bat

I think (it's been a while) that a .bat may run with Documents
and Settings as its current dir when you invoke it via
drag&drop or Sent To. I have notes about that somewhere ... if
you wish, I'll try harder to remember where.

J
--
Replies to: Nherr1professor2doktor31109(at)Oyahoo(dot)Tcom
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      4th Mar 2010


"Sid Elbow" <(E-Mail Removed)> wrote in message
news:4b8f0657$0$24276$(E-Mail Removed)...
> Pegasus [MVP] wrote:
>>
>>
>> "Sid Elbow" <(E-Mail Removed)> wrote in message
>> news:4b8ee111$0$14756$(E-Mail Removed)...
>>> I'm trying to run the following batch file:
>>>
>>>
>>> @echo off
>>>
>>> rem ***Set cbreak parms here, after the equals sign ***
>>> set cbreakparms=-b60 -d20 -s60
>>>
>>> :again
>>> if "%1"=="" goto end
>>> mkdir "%~dp1cbreak"
>>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>>> shift
>>> goto again
>>> :end
>>>
>>> It fails with the message:
>>>
>>> " 'cbreak' is not recognized as an internal or external command,
>>> operable program or batch file"
>>>
>>> .... yet the program cbreak.exe does exist and is in the same directory
>>> as the batch file. If I edit the batch file and give the full path to
>>> cbreak the batch will run correctly - I don't particularly want to do
>>> that since it will make the batch file location-dependent.
>>>
>>> Why does it not find cbreak in it's own directory?

>>
>> I suspect that the above is not the batch file that generates the error
>> message. I also can't quite see how the line
>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>> could work. AFAIR, the code you use requires a "for %%a in" construct.
>>
>> I would set "echo on" to see which line generates the error.

>
>
> Thanks for the response, Pegasus.
>
> I did as you suggested and turned echo on. It is indeed the line:
>
> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>
> which generates the error.
>
>
> Some background .... the program cbreak.exe is used (with some
> command-line parameters) to remove commercials from video files. The above
> batch file is used by drag-and-drop'ing a number of video files on to the
> batch file. In my (somewhat limited) understanding, this sets the batch
> file parameters (%1, %2, %3 etc) to the names of those files. The "shift"
> command is then used to present each file in turn to the cbreak.exe
> program along with an output directory and some control parameters.
>
> In fact, that part of the batch file seems to work if I put in the full
> path for cbreak.exe, but I don't understand why that is necessary (since
> all involved files are in the same directory).


OK, what happens when you invoke cbreak in its fully qualified form?

"c:\Some Folder\cbreak.exe" "%1" "%~dp1cbreak\%~nx1" %cbreakparms%

 
Reply With Quote
 
Sid Elbow
Guest
Posts: n/a
 
      4th Mar 2010
Pegasus [MVP] wrote:

>> I did as you suggested and turned echo on. It is indeed the line:
>>
>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>>
>> which generates the error.
>>
>>
>> Some background .... the program cbreak.exe is used (with some
>> command-line parameters) to remove commercials from video files. The
>> above batch file is used by drag-and-drop'ing a number of video files
>> on to the batch file. In my (somewhat limited) understanding, this
>> sets the batch file parameters (%1, %2, %3 etc) to the names of those
>> files. The "shift" command is then used to present each file in turn
>> to the cbreak.exe program along with an output directory and some
>> control parameters.
>>
>> In fact, that part of the batch file seems to work if I put in the
>> full path for cbreak.exe, but I don't understand why that is necessary
>> (since all involved files are in the same directory).

>
> OK, what happens when you invoke cbreak in its fully qualified form?
>
> "c:\Some Folder\cbreak.exe" "%1" "%~dp1cbreak\%~nx1" %cbreakparms%


Well, yes - that's what I meant by "....that part of the batch file
seems to work if I put in the full path for cbreak.exe". It works fine
under those circumstances - but then the batch file becomes specific to
that location: if I move the files to another directory I have to edit
the batch.

Incidentally, I did try putting a copy of cbreak.exe on the command path
(....\system32) but that didn't help.
 
Reply With Quote
 
Sid Elbow
Guest
Posts: n/a
 
      4th Mar 2010
Sid Elbow wrote:

> Incidentally, I did try putting a copy of cbreak.exe on the command path
> (....\system32) but that didn't help.


..... sorry - this did work after all. I have a multi-boot system (3xOS)
using the Windows boot manager and was using the wrong ....\Sytem32
directory when I wrote that. Duh!
 
Reply With Quote
 
Pegasus [MVP]
Guest
Posts: n/a
 
      4th Mar 2010


"Sid Elbow" <(E-Mail Removed)> wrote in message
news:4b8fc89a$0$15668$(E-Mail Removed)...
> Pegasus [MVP] wrote:
>
>>> I did as you suggested and turned echo on. It is indeed the line:
>>>
>>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>>>
>>> which generates the error.
>>>
>>>
>>> Some background .... the program cbreak.exe is used (with some
>>> command-line parameters) to remove commercials from video files. The
>>> above batch file is used by drag-and-drop'ing a number of video files on
>>> to the batch file. In my (somewhat limited) understanding, this sets the
>>> batch file parameters (%1, %2, %3 etc) to the names of those files. The
>>> "shift" command is then used to present each file in turn to the
>>> cbreak.exe program along with an output directory and some control
>>> parameters.
>>>
>>> In fact, that part of the batch file seems to work if I put in the full
>>> path for cbreak.exe, but I don't understand why that is necessary (since
>>> all involved files are in the same directory).

>>
>> OK, what happens when you invoke cbreak in its fully qualified form?
>>
>> "c:\Some Folder\cbreak.exe" "%1" "%~dp1cbreak\%~nx1" %cbreakparms%

>
> Well, yes - that's what I meant by "....that part of the batch file seems
> to work if I put in the full path for cbreak.exe". It works fine under
> those circumstances - but then the batch file becomes specific to that
> location: if I move the files to another directory I have to edit the
> batch.
>
> Incidentally, I did try putting a copy of cbreak.exe on the command path
> (....\system32) but that didn't help.


If the program works fine with a fully qualified path but fails when just
specifying "cbreak" then you're running something other than what you think
you run. In other words, there is a cbreak.com, .vbs, .bat or .cmd lurking
around that you have not considered so far. You can easily prove it like so:
- Rename cbreak.exe to MyCbreak.exe
- Modify the line
cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
to
MyCbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%


 
Reply With Quote
 
Sid Elbow
Guest
Posts: n/a
 
      4th Mar 2010
(E-Mail Removed)lid wrote:
> Sid Elbow <(E-Mail Removed)> wrote in


>>>> I'm trying to run the following batch file:
>>>>
>>>>
>>>> @echo off
>>>>
>>>> rem ***Set cbreak parms here, after the equals sign ***
>>>> set cbreakparms=-b60 -d20 -s60
>>>>
>>>> :again
>>>> if "%1"=="" goto end
>>>> mkdir "%~dp1cbreak"
>>>> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
>>>> shift
>>>> goto again
>>>> :end
>>>>
>>>> It fails with the message:
>>>>
>>>> " 'cbreak' is not recognized as an internal or external
>>>> command, operable program or batch file"
>>>>
>>>> .... yet the program cbreak.exe does exist and is in the
>>>> same directory as the batch file.


> Suggestion: add justt before "cbreak" a la
> cd
> pause


Tried that - it didn't help



> You need full path to the .exe because the path is relative to
> current dir, not to whatever is passed to the .bat
>
> I think (it's been a while) that a .bat may run with Documents
> and Settings as its current dir when you invoke it via
> drag&drop or Sent To. I have notes about that somewhere ... if
> you wish, I'll try harder to remember where.


I think you hit the nail on the head with this. When I tried your first
suggestion, I notice that command prompt during batch file operation
shows the current directory as ...\documents and Settings\<user>. So it
seems that if, in the GUI, I open a window to, say, E:/mydir containing
a .bat file, then drag-and-drop some files onto the .bat, windows runs
said batch file from the user-directory. That strikes me as less than
useful.

In any event, it seems I can get around it by putting the cbreak.exe
program on the command-path.
 
Reply With Quote
 
Sid Elbow
Guest
Posts: n/a
 
      4th Mar 2010
Pegasus [MVP] wrote:
>
>
> "Sid Elbow" <(E-Mail Removed)> wrote in message


>>>> In fact, that part of the batch file seems to work if I put in the
>>>> full path for cbreak.exe, but I don't understand why that is
>>>> necessary (since all involved files are in the same directory).
>>>
>>> OK, what happens when you invoke cbreak in its fully qualified form?
>>>
>>> "c:\Some Folder\cbreak.exe" "%1" "%~dp1cbreak\%~nx1" %cbreakparms%

>>
>> Well, yes - that's what I meant by "....that part of the batch file
>> seems to work if I put in the full path for cbreak.exe". It works fine
>> under those circumstances - but then the batch file becomes specific
>> to that location: if I move the files to another directory I have to
>> edit the batch.


> If the program works fine with a fully qualified path but fails when
> just specifying "cbreak" then you're running something other than what
> you think you run. In other words, there is a cbreak.com, .vbs, .bat or
> .cmd lurking around that you have not considered so far. You can easily
> prove it like so:
> - Rename cbreak.exe to MyCbreak.exe
> - Modify the line
> cbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%
> to
> MyCbreak "%1" "%~dp1cbreak\%~nx1" %cbreakparms%


As mentioned, error message produced states:

" 'cbreak' is not recognized as an internal or external command,
operable program or batch file"

that seems to mean that it can't find cbreak at all (in any command
form) so I'm not running something other than what I think: I'm not
running anything at all.


Nonetheless, I had previously tried using the full filename (cbreak.exe)
without success which should have eliminated the alternative command
forms but your suggestion was even better .... unfortunately it didn't
make any difference either.

I think the other response to the thread has pinpointed the problem.
Although I assumed that that, when I invoke a .bat from a specific
directory, the command shell would run it in that directory it seems
that's not what it does. It's apparently run in the current
user-directory - at least when you drag-and-drop to the batch file. I
frankly don't see any logic to that so perhaps its a genuine bug.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Batch File Problem Sash Microsoft Access VBA Modules 6 17th Jun 2008 05:17 PM
Batch file problem phil999 Microsoft Windows 2000 Registry 0 30th Jun 2007 11:47 AM
Problem with locked log file produced by batch file Ragnar Midtskogen Microsoft Windows 2000 CMD Promt 9 8th Dec 2006 02:04 AM
batch file problem CMAR Windows XP General 7 9th Nov 2004 01:59 AM
batch file - gp problem jim carney Microsoft Windows 2000 Group Policy 3 4th Aug 2003 06:20 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:18 PM.