Skip navigation

JSI Tip 8083. IfExist.exe freeware checks for the existence of a drive, folder, or file, and reports the drive type.


Download IfExist.zip and unzip to IfExist.exe to a folder in your path.

IfExist.txt contains:

IfExist.EXE : File/Dir/Drive Existence Utility : by Steven Wettberg
 
Usage: IfExist \[/ACTION\] \[ITEM TO TEST\]
 
/ACTION may be one of the following parameters
     /DRIVE      : Checks for the existence of a drive and reports the type.
     /FILE       : Checks for the existence of a file and reports the type
                   of drive on which it exists.
     /DIRECTORY  : Checks for the existence of a directory and reports the type
                   of drive on which it exists.
"ITEM TO TEST" may be a drive,file or directory depending upon the action.
 
The program checks for the existence the file,directory or drive, if the 
item exists an ERRORLEVEL indicating the drive type is returned.
An ERRORLEVEL of 7 indicates that the item does not exist
 
The ERRORLEVELs for the drive types are shown below.
ERRORLEVEL 1 = Unknown
ERRORLEVEL 2 = Removable
ERRORLEVEL 3 = Fixed
ERRORLEVEL 4 = Remote
ERRORLEVEL 5 = CDROM
ERRORLEVEL 6 = RamDisk
 
Examples
Usage: IfExist /DIRECTORY C:\SOMEDIR
Usage: IfExist /FILE C:\SOMEDIR\Test.Dat
Usage: IfExist /DRIVE C: 
Note: A UNC path may be used for directory and file existence.



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish