Welcome!

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

SignUp Now!

Buggy @full in do /s

Dec
73
1
I've encountered a bug with recursing directories and trying to get the path of the files, and a file name contains a ,

Batch file to reproduce the bug
Code:
@echo off
mkdir /ne testpath
touch /cq "testpath\File OK.txt"
touch /cq "testpath\File, BUG.txt"
do file in /s *.txt
    echo %file
    echo %@full[%file]
    echo %@path[%@full[%file]]
enddo

The output is on my system (TCC 28.02.18 x64 / Windows 10 [Version 10.0.17763.1397])

Code:
File OK.txt
C:\Users\USER\AppData\Local\Temp\x\testpath\File OK.txt
C:\Users\USER\AppData\Local\Temp\x\testpath\
File, BUG.txt
C:\Users\USER\AppData\Local\Temp\x\testpath\BUG.txt\File
C:\Users\USER\AppData\Local\Temp\x\testpath\BUG.txt\

The filename with , gets split if @full tries to get the path. Any workaround is welcome - thanks!
 
No workaround necessary. Simply use correct syntax.

Code:
%@FULL["%file"]

Always quote variables unless you explicitly want to enable sideeffects.
 
See the help file for the @FULL function. @FULL can take two parameters, separated by... a comma.

Quoting filenames is indeed a good habit.
 
You can use the %@quote[] function to quote material only when necessary. So %@quote[12] produces just 12, while %@quote[1,2] produces "1,2".
 
Right, that's it - thanks everyone, I'll change my scripts to quoted vars if necessary, and I didn't see the second param for @full - it's probably usefull to look at the help file again :-)
 

Similar threads

Back
Top