Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? processing filenames

Oct
356
2
Helo -- I am reading a file into an array -- the file content is filenames -- as it turns out the names of the files in the list contains trigger characters that is causing tcc to try to process it -- one such character is & --

is there a way to quote the filename in the array so there the name is processed as-is --

I recall in the unix world use ' will do this --

thanks
 
Double-quotes will defang most problem characters, including ampersand.
 
Hello –

It seems that the quotes work some of the times –

here is my simple bat file to show the content

@echo off
setlocal

set loc=%@path[%_batchname]
unsetarray /q filelist
set files=%[loc]music-files.txt

setarray /r %files filelist
set dim=%@arrayinfo[filelist,0]
set count=%@arrayinfo[filelist,1]
echo %dim %count
set /a last=%count - 1

do ii=0 to %last
set fid="%filelist[%ii]"
echo %@fileage[%fid] %@unquotes[%fid]
enddo

quit

iit seems that the script is breaking on this line –

j:\music\archive\flac\delaney & bonnie\a & r studios 1971\01. announcer.flac
 
ECHO won't work if you @UNQUOTES the file name containing the &. That command turns into
Code:
 ECHO <file age> j:\music\archive\flac\delaney & bonnie\a & r studios 1971\01. announcer.flac
I imagine that "bonnie\a" will be an unknown command.
 
yes -- that is what is happening -- is there a way to get the (file) name process without any scanning?
 
yes -- that is what is happening -- is there a way to get the (file) name process without any scanning?

Various ways. You can disable the command separator with SETDOS /X-5 (this will also disable some other features like pipes and redirection).

Or you can change the command separator to something that will never occur in a filename with e.g. SETDOS /C24. With this approach, you can use %+ to represent the command separator.

Either way, you want to do it in a SETLOCAL/ENDLOCAL block, so the temporary weirdness is reverted once you're finished.
 

Similar threads

Back
Top