How to? processing filenames

Oct 18, 2008
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 --

Oct 18, 2008
Hello –

It seems that the quotes work some of the times –

here is my simple bat file to show the content

@echo off

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]


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
 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.

Charles Dye

Super Moderator
Staff member
May 20, 2008
Albuquerque, NM
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.