Skip to content

Commit 9fde0c1

Browse files
committed
Checks to see if a directory exists in the users home directory, if not then create it
1 parent f1cc0ad commit 9fde0c1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

create_dir_if_not_there.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1-
import os
2-
home=os.path.expanduser("~")
3-
print home
4-
if not os.path.exists(home+'/testdir'):
5-
os.makedirs(home+'/testdir')
1+
# Script Name : create_dir_if_not_there.py
2+
# Author : Craig Richards
3+
# Created : 09th January 2012
4+
# Last Modified :
5+
# Version : 1.0
6+
# Modifications :
7+
8+
# Description : Checks to see if a directory exists in the users home directory, if not then create it
9+
10+
import os # Import the OS module
11+
home=os.path.expanduser("~") # Set the variable home by expanding the users set home directory
12+
print home # Print the location
13+
if not os.path.exists(home+'/testdir'): # Check to see if the directory exists
14+
os.makedirs(home+'/testdir') # If not create the directory, inside their home directory

0 commit comments

Comments
 (0)