|Purpose:||Execute a command in the current directory and its subdirectories|
|Format:||GLOBAL [/H /I /J /N /P /Q /S[+]n] command|
|command||The command to execute, including parameters and switches.|
GLOBAL performs command first in the current directory. Then it makes every subdirectory under the current directory the current working directory in turn, and performs command in that directory. Command can be an internal command, an alias, an external command, or a batch file. When command is executed, it may be necessary to utilize one of the variable functions which convert a relative path to an absolute one, e.g., @truename, @full, etc to make sure that files of the same name in different directories are correctly handled.
If you don't specify any arguments, GLOBAL will display its command dialog.
The example below copies the files in every directory on drive A to the directory C:\TEMP:
[a:\] global copy * c:\temp
If a specific filename is found in more than one directory on A:, assuming COPY is the default internal command, the one found last will be left in C:\TEMP. Which one of multiple, identically named files is found last is unpredictable!
If you use the /P option, GLOBAL will prompt for each subdirectory before performing command. You can use this option if you want to perform command in most, but not all subdirectories of the current directory.
You can use command grouping to execute multiple commands in each subdirectory. For example, the following command copies each .TXT file in the current directory and all of its subdirectories to drive D. It then changes the extension of each of the copied files to .SAV:
global (copy *.txt d: & ren *.txt *.sav)
The default output redirection (i.e., global command > filename) creates a new output file named filename as each directory visited. If filename does not include an absolute file path, these files will be created relative to the currently visited directory. If filename does include an absolute file path, that file will be overwritten as each directory is visited, and only the data from the last visited directory will survive.
The simplest way to force a single target file is to enclose the whole command line in parentheses, e.g.,:
(global command) > filename
|/=||Display the GLOBAL command dialog to help you set the command line options. You cannot specify any other arguments on the command line.|
|/H||Forces GLOBAL to look for hidden directories. If you don't use this switch, hidden directories and their subdirectories are ignored without error indication.|
|/I||If this option is not specified, GLOBAL will terminate if command returns a non-zero exit code. Use /I if you want command to continue in additional subdirectories even if it returns an error in one subdirectory. GLOBAL will normally halt execution if TCC receives a Ctrl-C or Ctrl-Break even if you use /I.|
Without this option, if GLOBAL is unable to change to a directory (for example, if user does not have access rights), GLOBAL will stop with an error message. With this option set, GLOBAL will ignore that directory, and all of its subdirectories, and continue in the next accessible directory.
|/P||Forces GLOBAL to prompt with each directory name before it performs command in that directory. Your options at the prompt are explained in detail under Page and File Prompts.|
|/S||GLOBAL will limit the subdirectory recursion to the number specified. For example, if you have a directory tree "\a\b\c\d\e", /S2 will only go to the "a", "b", and "c" directories.|
If you specify a + followed by a number after the /S, GLOBAL will not execute command until it gets to that depth in the subdirectory tree. For example, if you have a directory tree \a\b\c\d\e, /S+2 will not execute command in \a or \a\b.