Skip to content

Commit 9619c86

Browse files
committed
This will list all the files in the given directory, it will also go through all the subdirectories as well
1 parent d3a8652 commit 9619c86

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

script_listing.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
# Script Name : script_listing.py
22
# Author : Craig Richards
33
# Created : 15th February 2012
4-
# Last Modified :
5-
# Version : 1.1
4+
# Last Modified : 29th May 2012
5+
# Version : 1.2
6+
67
# Modifications : 1.1 - 28-02-2012 - CR - Added the variable to get the logs directory, I then joined the output so the file goes to the logs directory
8+
# : 1.2 - 29-05/2012 - CR - Changed the line so it doesn't ask for a directory, it now uses the environment varaible scripts
79

810
# Description : This will list all the files in the given directory, it will also go through all the subdirectories as well
911

1012
import os # Load the library module
1113

1214
logdir = os.getenv("logs") # Set the variable logdir by getting the value from the OS environment variable logs
1315
logfile = 'script_list.log' # Set the variable logfile
16+
path = os.getenv("scripts") # Set the varable path by getting the value from the OS environment variable scripts - 1.2
1417

15-
path = (raw_input("Enter dir: ")) # Ask the user for the directory to scan
18+
#path = (raw_input("Enter dir: ")) # Ask the user for the directory to scan
1619
logfilename=os.path.join(logdir, logfile) # Set the variable logfilename by joining logdir and logfile together
1720
log = open(logfilename, 'w') # Set the variable log and open the logfile for writing
1821
for dirpath, dirname, filenames in os.walk(path): # Go through the directories and the subdirectories

0 commit comments

Comments
 (0)