Monday, July 7, 2008

Stupid Scripting Tip 109: IF EXIST (FOLDER)

The CMD shell allows you to write some nifty script code. Not as crazy as VBscript or Kixtart or PowerShell obviously, but still, very useful. Sometimes a BAT/CMD script is the best solution. Actually more often than you'd think.

So, the IF EXIST statement is a very common tool, but you can only test for FILE objects with it, not FOLDER objects. However, thanks to the inherent NUL object, you can! Simply append \NUL on the end of a folder path to test for it using IF EXIST.


Works great.
Post a Comment