Windows .cmd script hints
Ensuring command extensions are active
set DUMMY=Dummyif not !DUMMY!==Dummy cmd.exe /e:on /v:on /c %0 %1 %2 %3 %4 %5 %6 %7 %8 %9if not !DUMMY!==Dummy goto end rem do much work:end
Parameter %0-%9 and variable %foo expansion functions
Most of these ~ functions can be combined.
| Expands %1, removes surrounding quotes (") |
|
| Expands %1 to a fully qualified pathname |
|
| Expands %1 to a drive letter only |
|
| Expands %1 to a path only |
|
| Expands %1 to a filename only |
|
| Expands %1 to a file extension only |
|
| Changes the meaning of n and x options to reference the short name instead. |
|
| Searches the directories listed in the PATH environment variable and expands %1 to the fully qualified name of the first one found or empty string if nothing found. |
|
| Expands %1 to the file's attributes |
|
| Expands %1 to the file's date/time |
|
| Expands %1 to the file's size |
|
Feel free to play with my sandbox script petest.cmd.
From: IBCL BLog.
Originally posted: 2009-01-16