home *** CD-ROM | disk | FTP | other *** search
- Testing for DEVICE NAMES
-
- As stated in the CONDITION topic, EXIST always succeeds for a file. Some files
- that always exist in every directory are the device names, including NUL, AUX,
- and PRN. Files that are device names cannot be deleted or COPYed, so it is
- possible for an IF test to determine whether X (which may be an environment
- variable, replaceable parameter, or explicit FOR loop-variable) is a device
- name. For example:
-
- IF EXIST X DEL X
- IF EXIST X ECHO X is a device name or a read-only file
-
- DEL FUNNYFIL
- IF EXIST X COPY X FUNNYFIL
- IF EXIST X IF NOT EXIST FUNNYFIL ECHO X is a device name or 0-length file
-
- MD FUNNYDIR
- IF EXIST FUNNYDIR\X ECHO X is a device name
- RD FUNNYDIR
-
- Any non-existent file or directory name can be used in place of FUNNYFIL and
- FUNNYDIR, above.