AnsweredAssumed Answered

Writing all files in a folder to a log file.

Question asked by jaxelrodmfa on Sep 4, 2012
Latest reply on Sep 4, 2012 by jaxelrodmfa
I'm hoping someone can help me with a piece of code to list all of the files in my output workspace.

ListFiles works for the current workspace however, the files I need to list are in a different workspace. The current workspace contains all of my input files which are in a geodatabase but, the output files are being sent to a folder and contain only tables and a read me file. The read me file lists the processing steps, date, and time of processing but, I also need it to list the names of the tables (.dbf) which are in the folder. Below is not the entire script, just the pieces relevant to the read me file.

Thanks!


# Import arcpy module
import arcpy, sys, traceback, time, datetime

#Set Read me file workspace
CURDATE = datetime.date.today()
logpath = "C:\\Script\Output\ReadMe"
logfile1 = logpath + str (" ") + str(CURDATE) + ".txt"


if arcpy.Exists(logfile1):
    arcpy.Delete_management(logfile1)

log1 = open(logfile1, "a")

print str(CURDATE) + " Generate Readme file"
print >> log1, time.strftime("%c")

#Set the current workspace for input file geodatabase
arcpy.env.workspace = "C:\\Script\Input.gdb"

#Set Local variables specifyting the output table folder:
outTable = "C:\\Script\Output\"


### - Processing steps are here

print "Write .dbf tables to log file"
print >> log1, "Files generated = "
##print >> log1, INSERT FUNCTION TO LIST ALL FILES IN OUTPUT FOLDER
print "End logging"

log1.close()

Outcomes