-
Notifications
You must be signed in to change notification settings - Fork 17
/
exist.bat
73 lines (45 loc) · 1.71 KB
/
exist.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
@echo off
rem Check for existence of a file and directory
rem Note: this doesn't seem to work on Microsoft Networking network drives
rem
Create a file and a directory
echo > testfile
md testdir
rem testfile is a file
rem testdir is NOT a file
if exist testfile echo testfile is a file
if exist testdir echo testdir is a file
rem testfile is NOT a directory
rem testdir is a directory
if exist testfile\nul echo testfile is a directory
if exist testdir\nul echo testdir is a directory
rem testfile is a file
rem testdir is NOT a file
if not exist testfile echo testfile is not a file
if not exist testdir echo testdir is not a file
rem testfile is NOT a directory
rem testdir is a directory
if not exist testfile\nul echo testfile is not a directory
if not exist testdir\nul echo testdir is not a directory
echo Cleaning up
rem
rem Now remove both the file and the directory
rem
del testfile
rd testdir
rem testfile is no longer a file
rem testdir was never a file to begin with
if exist testfile echo testfile is a file
if exist testdir echo testdir is a file
rem testfile was never a directory to begin with
rem testdir is no longer a directory
if exist testfile\nul echo testfile is a directory
if exist testdir\nul echo testdir is a directory
rem testfile is no longer a file
rem testdir was never a file to begin with
if not exist testfile echo testfile is not a file
if not exist testdir echo testdir is not a file
rem testfile was never a directory to begin with
rem testdir is no longer a directory
if not exist testfile\nul echo testfile is not a directory
if not exist testdir\nul echo testdir is not a directory