escaping the % of filenames ???
Posted: 18 Nov 2011 11:24
Hi all
A very last question before the next one
I'm trying to undestand how we should manipulate filename given in parameters by third part application.
My batchs still have issues with some specials chars.
1. First, I think every time we have to assign a var to a filename, we should have Delayed Expansion disabled, like this:
By working like this, we'll never have to escape chars in the main batch???
Am I right or wrong???
2. The % issue
As an example, let's take a file named a%b.bat:
In this case, new_file.bat won't work because the % of a%b.bat has to be escaped...
but how??? I didn't found the solution
Thanks for help
A very last question before the next one
I'm trying to undestand how we should manipulate filename given in parameters by third part application.
My batchs still have issues with some specials chars.
1. First, I think every time we have to assign a var to a filename, we should have Delayed Expansion disabled, like this:
Code: Select all
setlocal DisableDelayedExpansion
set "_file1=%~1"
set _file1& rem "%_file1%" will work with any characters, in any command line
setlocal EnableDelayedExpansion
set _file1& rem "!_file1!" will also work with any characters, in any command line
Am I right or wrong???
2. The % issue
As an example, let's take a file named a%b.bat:
Code: Select all
set "_file=%~nx0"
set _file
>"new_file.bat" echo call "%_file%"
but how??? I didn't found the solution
Thanks for help