Hello all,I have a script that renames a file with a generic name to one reflecting its week ending date. In addition to the rename process, the script also outputs a string that is to be used as a model variable. This string is the prefix portion of the renamed file name (e.g., clm20130914). If this string can be set as a model variable, then all the remaining steps of the model will name the intermediate and final output files accordingly. The problem is, I cannot seem to assign a script's string output as a string variable within the model. Does anyone have any insight on how to do this? The line containing arcpy.SetParameterAsText(2, i[4])
should assign i[4] as the third parameter, correct? I have assigned the third parameter as a derived output. The following is the script for the model's rename portion, and attached is a graphic of the model. Any help would be greatly appreciated. import datetime,csv,sys,os,arcpy from datetime import date todays_date = datetime.date.today() todays_date = todays_date.strftime("%Y %m %d") todays_date = todays_date.split() todays_date = map(int, todays_date) todays_date = date(todays_date[0], todays_date[1], todays_date[2]) calendar = csv.reader(open(sys.argv[1])) calendar.next() calendar.next() calendar.next() l = reversed(list(calendar)) for i in l: try: file_date = i[0].split('/') file_date = '20' + file_date[2] + ' ' + file_date[0] + ' ' + file_date[1] file_date = file_date.split() file_date = tuple(map(int, file_date)) file_date = date(file_date[0], file_date[1], file_date[2]) if todays_date >= file_date: current_file = i[4] + '.ides.csv' arcpy.SetParameterAsText(2, i[4]) break except IndexError: pass rename_file = os.listdir('W:\WDIA_Production\Geocoding_Files')[0] os.rename(os.path.join(sys.argv[2], rename_file),os.path.join(sys.argv[2],current_file))