kelseymquinlan

Python for renaming file paths

Discussion created by kelseymquinlan on Apr 28, 2017
Latest reply on Apr 29, 2017 by curtvprice

Hello all,

 

I am fairly new to python and am having issues renaming file paths within a table. I need to replace all of my \ for / within a field. \ is an escape so it is not working. Here is a brief snippet of my code:

arcpy.CalculateField_management(in_table="Assess", field="IMAGELINK", expression="""!IMAGELINK!.replace(r"\","/")""", expression_type="PYTHON_9.3", code_block="")

 

I know there are easy ways to do this with VB and with field calculator but I am trying to automatic a much bigger table update.

 

edit: I've tried using \ \ instead and still had no luck.

edit 2: This is ultimately what worked for me, thank you Joshua

expression=r"""!IMAGELINK!.replace("\\","/")"""

 

 

Any advice is much appreciated! Thanks

Outcomes