Saved Bookmarks
| 1. |
Solve : Check if a folder exist...? |
|
Answer» Hi there I've spent the last hours trying to move some files... that does work- and all this time I've been doing "if exist <foldername>\nul <command>" Checking for \nul is a venerable way of checking if a folder or drive exists. NUL always exists on a local MS-DOS FAT drive; therefore, if C:\ exists, then C:\NUL exists, and if C:\WIN exists, C:\WIN\NUL exists. However it does not work in EVERY situation, and therefore is regarded as obsolete, and is not needed in NTFS. The following table shows when IF EXIST returns NUL: With 32-Bit File No 32-Bit With 32-Bit Access and NetWare Drive Type File Access File Access 3.x connectivity Local FAT correctly always never Windows for Workgroups FAT correctly always never Microsoft LAN MANAGER HPFS never always never Windows NT FAT/NTFS never always never NetWare correctly never never It's just a habit from my old batch programming days with DOS 3.21 since I don't really use batch anymore I don't have a bunch of batch files in my C:\BELFRY directory peppered with TESTS for the NUL file. Back when I first started I used If exist dir\*.*, which worked if there were any files. But without files it didn't work. MS-DOS is phat. I was taught this way to check for a folder. Code: [Select]if exist folder\. command Every folder has a . directory, even if empty, so this test works in all versions. Quote from: llmeyer1000 on May 23, 2008, 08:38:06 PM I was taught this way to check for a folder. we have a winner! |
|