Select to view content in your preferred language

to rename a table where the date can be part of the name

3650
5
05-18-2011 11:26 AM
CarlosFlores1
Deactivated User
I am trying to include a line on my script that will rename a table with "ARM" +Date (current date).  I am new in python and really do not know where to find this information. I am using ArcGIS 9.3 with an ArcInfo license. Here is the line that I have:

# Process: Rename...
gp.Rename_management(NewAMR, AMR+?)

Thanks
Tags (2)
0 Kudos
5 Replies
MathewCoyle
Honored Contributor
http://docs.python.org/release/2.6.5/library/datetime.html

Gives you all the info you need depending on how you want your date formatted.
0 Kudos
CarlosFlores1
Deactivated User
Thanks, I could get the date in the script but I can not concatenate the string "AMR" with the date after that. (AMR20111705).  Any help on this? thanks
0 Kudos
AlessandroCinnirella
Regular Contributor
use "AMR" + str(yourdate)

AC
0 Kudos
CarlosFlores1
Deactivated User
Thanks for your help. The rename tool process does not take the date as a part of the renaming name for some reason. I used the "AMR" + str(date) and did not work, I even changed this several times to a diferent format and is not taking it. Any Ideas?  It works ok if I use the time in a separate script :

import time
from datetime import date
time = date.today()
#print time
STRING = "AMR"
print STRING + str(time)

If I try to use this in the rename tool process it does not take it.  Help
0 Kudos
DarrenWiens2
MVP Alum
I don't think you can use an expression in the actual function call (ie. you can't type "AMR" + str(date) in the parentheses for gp.Rename_management). What you can do is pass a variable into the function call.

datestring = "AMR" + str(date)
gp.Rename_management(NewAMR, datestring)
0 Kudos