0

I am performing a certain operation on a number of files and following is the bat file script written for it. names of the files are of this type: aspen_1M_bursty_25_1.pcap

@FOR /L %%i in (1,1,10) do (
   @%decoder% -i L:\martin\05_distorted\Elecard\%~n1_bursty_25_%%i.pcap -o L:\martin\05_distorted\Elecard\%~n1_bursty_25_%%i.avi
)

Th problem is, this script adds '-' inside and ends up calling the command like the following:

-i L:\martin\05_distorted\Elecard\-_bursty_25_1.pcap -o L:\martin\05_distorted\Elecard\-_bursty_25_1.avi 
                                  ^                                                    ^

Hence it would return an error that there is no such file as the names of the files have no '-' in them:

The above script is in a bat file and I am calling the bat file through command prompt.

How to get rid of this '-' thing? :)

2
  • How are you running the script? Please show the full commandline. Commented Sep 6, 2013 at 12:56
  • 1
    The output redirection operator is >, not ->. Use name.bat aspen_1M >log.txt. Commented Sep 6, 2013 at 16:04

1 Answer 1

1

The problem is in the %~n1 substitution parameter. Read HELP CALL to understand how this works.

In your case, %1 is the first parameter passed to your code.

So you need to review the way you invoke this code.

If this a :label being CALLed, then review the CALL command.

If it is in the main BAT script, then review the way you invoke the BAT from the command line, or from another BAT.

It seems that you are passing "-".

name.bat ->log.txt

If you, instead, pass "aspen" it should work correctly. This way:

name.bat aspen >log.txt
Sign up to request clarification or add additional context in comments.

1 Comment

sorry, but the answer solves your problem. You are actually passing a "-" parameter. So, instead of name.bat ->log.txt invoke it as name aspen >log.txt

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.