ZTree.com  | ZEN  | About...  

 Index   Back

Set quoting   [OT]

By: Ben Kent       
Date: Jan 12,2023 at 09:17
In Response to: [OT] Example BAT script (Slobodan Vujnovic)

> If you can't wrap your mind around nested FOR loops, this can
> get you started. By the way, I've never seen such use of double
> quotes in the SET command.
>

Slobodan

When I first saw the [set "var=%1"] syntax at work some years ago, I thought it was an error. So I did some investigating and it's valid syntax. So now I know of that syntax I use it in new scripts.


Notes

This puts quotes in the environment variable, which can make using the value difficult if you need to combine strings
Set var="%1"

So sometimes you have to do things like this, to get rid of the spare quotes
dir "c:\SomeDir\%var:"=%"



This sets the value without the quotes, which can make using the value easier
Set "var=%1"

The usage is simpler
dir "c:\SomeDir\%var%"

Ben

51 views      
 

Messages in this Thread

 
96,194 Postings in 12,153 Threads, 350 registered users, 34 users online (0 registered, 34 guests)
Index | Admin contact |   Forum Time: Jan 27, 2023 - 12:49 am UTC  |  Hits:53,203,459  (692 Today )
RSS Feed