|
1 |
| -# Script Name : create_dir_if_not_there.py |
2 |
| -# Author : Craig Richards |
3 |
| -# Created : 09th January 2012 |
4 |
| -# Last Modified : 22nd October 2015 |
5 |
| -# Version : 1.0 |
6 |
| -# Modifications : Added exceptions |
| 1 | +# Script Name : create_dir_if_not_there.py |
| 2 | +# Author : Craig Richards |
| 3 | +# Created : 09th January 2012 |
| 4 | +# Last Modified : 22nd October 2015 |
| 5 | +# Version : 1.0.1 |
| 6 | +# Modifications : Added exceptions |
| 7 | +# : 1.0.1 Tidy up comments and syntax |
| 8 | +# |
| 9 | +# Description : Checks to see if a directory exists in the users home directory, if not then create it |
7 | 10 |
|
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 | +import os # Import the OS module |
11 | 12 | try:
|
12 |
| - home=os.path.expanduser("~") # Set the variable home by expanding the users set home directory |
13 |
| - print home # Print the location |
14 |
| - if not os.path.exists(home+'/testdir'): |
15 |
| - os.makedirs(home+'/testdir') # If not create the directory, inside their home directory |
16 |
| - except Exceptions as e: |
17 |
| - print e |
| 13 | + home = os.path.expanduser("~") # Set the variable home by expanding the users set home directory |
| 14 | + print home # Print the location |
| 15 | + |
| 16 | + if not os.path.exists(home+'/testdir'): |
| 17 | + os.makedirs(home+'/testdir') # If not create the directory, inside their home directory |
| 18 | + except Exceptions as e: |
| 19 | + print e |
0 commit comments