Reputation: 5
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? :)
Upvotes: 0
Views: 72
Reputation: 29369
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
Upvotes: 1