Purpose:Perform a command on all available files except those specified

 

Format:EXCEPT [/I"text" /N[em]] [(@file) | (file ...)] command

 

fileThe file or files to exclude from the command.
@fileA text file containing the names of the files to exclude, one per line (see @file lists for details).
commandThe command to execute, including all appropriate parameters and switches.

 

/I (match description)        /NM (no matches)

/Ne (no errors)

 

See also: ATTRIB and File Exclusion Ranges.

 

File Selection

 

Supports extended wildcards, ranges, multiple file names, and include lists. Date, time, size, or file exclusion ranges must appear immediately after the EXCEPT keyword.

 

Use wildcards with caution on LFN volumes; see LFN File Searches for details.

 

Usage:

 

EXCEPT provides a means of executing a command on a group of files and/or subdirectories, and excluding a subgroup from the operation. The command can be an internal command or alias, an external command, or a batch file. Using internal commands with EXCEPT is not recommended. File exclusion ranges provide a faster and more flexible method of excluding files from internal commands, and do not manipulate file attributes, as EXCEPT does. However, exclusion ranges can only be used with internal commands; you must use EXCEPT for external commands.

 

You may use wildcards to specify the files to exclude from the command. When you use EXCEPT on an LFN drive, you must quote any file names inside the parentheses which contain white space or special characters.

 

EXCEPT will assume that the files to be excluded are in the current directory, unless another directory is specified explicitly.

 

EXCEPT prevents operations on the specified file(s) by setting the hidden attribute, performing the command, and then clearing the hidden attribute. If the command is aborted in an unusual way, you may need to use the ATTRIB command to remove the hidden attribute from the file(s). Files which already had the hidden attribute, and are included in the set matching EXCEPT, will not be hidden after EXCEPT is competed. The hidden attribute of files not matching EXCEPT will not be changed.

 

Caution: EXCEPT will not work with programs or commands that ignore the hidden attribute or which work explicitly with hidden files, including DEL /Z, and the /A:H or /H (process hidden files) switches available in internal file processing commands.

 

Date, time, and size ranges can be used immediately after the word EXCEPT to further qualify which files should be excluded from the command. If the command is an internal command that supports ranges, an independent range can also be used in the command itself. You can also use a file exclusion range within the EXCEPT command; however, this will select files to be excluded from EXCEPT, and therefore included in execution of the command.

 

You can use command grouping to execute multiple commands with a single EXCEPT. For example, the following command copies all files in the current directory whose extensions begin with .DA, except the .DAT files, to the D:\SAVE directory, then changes the first two characters of the extension of the copied files to .SA:

 

except (*.dat) (copy *.da* d:\save & ren *.da* *.sa*)

 

If the last argument on the line is a single (, it is interpreted as the beginning of a command group. EXCEPT will append the following lines (in a batch file) or prompt you for more input (at the command line) until it gets a closing ).

 

Option:

 

/I"text"Select files by matching text in their descriptions. The text can include wildcards and extended wildcards. The search text must be enclosed in double quotes, and must follow the /I immediately, with no intervening spaces. You can select all filenames that have a description with /I"[?]*", or all filenames that do not have a description with /I"[]". Do not use /I with @file lists. See @file lists for details.

 

/NeDon't display an error message if EXCEPT can't find a matching file.

 

/NMIf EXCEPT cannot find any file matches for the arguments in the exception list, EXCEPT will not execute the command.