This should be a simple answer ... I'm trying to just remove the first 25 characters from a list (>90 in number) of Feature classes (raster datasets) within a .gdb.
All the file names are named the same except for the last 9 digits (hence why I am trying to remove the first 25).
I would then like to add some standard text to all the FCs (in the example "Hello")
My attempt from other threads comprises the following (but has not worked so far):
-------------------
import arcpy
import os
dir = r'C:\Users\X\Desktop\X\X.gdb'
arcpy.env.workspace = dir
for ras in arcpy.ListRasters ("*"):
print (ras) #original raster name
basename = ras.split("*")[:25] #strips the first 25 characters from original raster name
newrastername = "Hello" + basename
print (newrastername)
arcpy.CopyRaster_management(ras, newrastername) #create a new raster with the new/updated name
----------------------
Error received:
---------------------------------------------------------------------------
SyntaxError Traceback (most recent call last)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\ast.py, in parse:
Line 35: return compile(source, filename, mode, PyCF_ONLY_AST)
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(ras #original raster name)? (<string>, line 😎