When writing batch
FOR loops I've picked up a habit of using
tildes in the variable placeholder names in the command portion of the script and enclose that with double quotes.
FOR %%A IN ("*.*") DO ECHO "%%~A"
I usually write scripts like this as a standard whether or not they are truly needed without thought. I like how it strips the double quotes from the
set portion of the loop and then adds them back explicitly in the
command parameter portion of the loop.
Could there be a scenario where using the tilde could actually be harmful when used with a
FORloop via batch script or command line?
What are some reasons from others experience or perhaps officially documented somewhere why you would or would not want to use
tildesfor this reason with
FORloops via cmd or batch?