Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
Variables in Windows batch files
Name: dskw Date: July 8, 2005 at 20:11:53 Pacific OS: XP Pro SP2 CPU/Ram: 1.8 GHz P4 / 768MB DDR
Comment:
How can I resolve a variable inside a variable? For instance:
@echo off set abc=123 set no123=success echo Should display success echo %no%abc%% pause
The above commands should display the string 'success'. However, it doesn't. What I would like to do is to resolve %no%abc%% to %no123% (since %abc%=123) then resolve %no123% to 'success'. Any solutions? Thanks in advance.
You need to enable the "delayed expansion of variables" then you have to use the ! symbols for the external variable noXXX and % for the inner one abc (the index).
Your code would be as the following
@echo off SetLocal EnableDelayedExpansion
set abc=123 set no123=success echo Should display success echo !no%abc%!
Summary: In my batch file (see code below) the Xname variable is set by a command line parameter. How would I go about prompting the user with a text input box and have the Xname variable set by the text giv...
Summary: Hi I wrote a batch for WinXP to delete files older than a certain number of days, as I'm english I guess than I would have to change the date variables in the batch file. ie this command typed at th...
Summary: I need the size of folders in kb,mb gb... or just b... dir doesn't list the size of folders, only files. for example: on linux I can type du -h --max-depth=1 /home/js/dir.txt and that gives me the siz...