<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Removing characters from rasters and putting them to the front of file name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180272#M13852</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The answers above don't take case into account, which is the variation that you mentioned.&amp;nbsp; You should add a .lower() function to the string. This will evaluate the string as a lowercase version of itself.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if ras.lower().endswith("_pa"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #rename the raster
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I just tested and the split function is case sensitive, so you'll have to watch out for that.&amp;nbsp; What I suggested above works in this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
name1 = "harrisburg_pa"
name2 = name1[:-3] #remove the last 3 characters, regardless of what they are
name3 = "PA_" + name2 #adds "PA_" to the beginning of the new name
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;So, regardless of whether or not the raster ends in "_pa", the last three characters will be removed.&amp;nbsp; This may not be desirable, so you may want to filter the rasters by using the if statement that jamesfreddyc suggested.&amp;nbsp; Just be careful because python is case sensitive.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 09:13:11 GMT</pubDate>
    <dc:creator>AdamCox1</dc:creator>
    <dc:date>2021-12-11T09:13:11Z</dc:date>
    <item>
      <title>Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180266#M13846</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I need syntax in Arcpy/python that will remove "_pa" from the end of any raster file that has this at the end of its file name. Additionally, on files where this is the case, I want to add "PA_" to the front of these files. Can anyone help me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 12:46:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180266#M13846</guid>
      <dc:creator>AndrewTuleya2</dc:creator>
      <dc:date>2014-05-29T12:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180267#M13847</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's some info on the correct tool to use:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000056000000" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000056000000&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's an example of how to reconstruct the name:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
name = "original_pa"
newname = "PA_" + name[:-3]
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that solves it!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180267#M13847</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T09:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180268#M13848</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This should get you pretty close to what you need I think.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
import os

dir = r'H:\Documents\ArcGIS\Default.gdb'
arcpy.env.workspace = dir

for ras in arcpy.ListRasters("*_pa"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; print ras #original raster name
&amp;nbsp;&amp;nbsp;&amp;nbsp; basename = ras.split("_pa")[0] #strip _pa from original raster name
&amp;nbsp;&amp;nbsp;&amp;nbsp; newrastername = "PA_" + basename 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print newrastername
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(ras, newrastername) #create a new raster with the new/updated name

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180268#M13848</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T09:13:08Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180269#M13849</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the reply! What if the file name is not consistent? For example, one raster in the geodatabase is called York_pa and another is Harrisburg_PA, and I want the command to take care of all file names with _pa as the last 3 characters?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 13:16:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180269#M13849</guid>
      <dc:creator>AndrewTuleya2</dc:creator>
      <dc:date>2014-05-29T13:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180270#M13850</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Thanks for the reply! What if the file name is not consistent? For example, one raster in the geodatabase is called York_pa and another is Harrisburg_PA, and I want the command to take care of all file names with _pa as the last 3 characters?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;That's what this does in my solution I provided:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; arcpy.ListRasters("*_pa") &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: if you must absolutely ensure that the last 3 characters are evaluated, then you could use the .endswith property.&amp;nbsp; Here's a modified version of my OP:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt; for ras in arcpy.ListRasters(): &amp;nbsp;&amp;nbsp;&amp;nbsp; if ras.endswith("_pa"):&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename = ras.split("_pa")[0] &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrastername = "pa_" + basename &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyRaster_management(ras, newrastername) &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 13:22:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180270#M13850</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-05-29T13:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180271#M13851</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks! Ill give it a go right now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 13:27:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180271#M13851</guid>
      <dc:creator>AndrewTuleya2</dc:creator>
      <dc:date>2014-05-29T13:27:07Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180272#M13852</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The answers above don't take case into account, which is the variation that you mentioned.&amp;nbsp; You should add a .lower() function to the string. This will evaluate the string as a lowercase version of itself.&amp;nbsp; For example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if ras.lower().endswith("_pa"):
&amp;nbsp;&amp;nbsp;&amp;nbsp; #rename the raster
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, I just tested and the split function is case sensitive, so you'll have to watch out for that.&amp;nbsp; What I suggested above works in this way:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
name1 = "harrisburg_pa"
name2 = name1[:-3] #remove the last 3 characters, regardless of what they are
name3 = "PA_" + name2 #adds "PA_" to the beginning of the new name
&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;So, regardless of whether or not the raster ends in "_pa", the last three characters will be removed.&amp;nbsp; This may not be desirable, so you may want to filter the rasters by using the if statement that jamesfreddyc suggested.&amp;nbsp; Just be careful because python is case sensitive.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180272#M13852</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T09:13:11Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180273#M13853</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;If you're importing os anyway, you can also use os.rename() rather than copying the raster. Rest is what James &amp;amp; Adam wrote about getting the name correctly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

for ras in arcpy.ListRasters():&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; if ras.lower.endswith("_pa"):&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basename = ras.split("_pa")[0]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; newrastername = "pa_" + basename&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; os.rename(ras, newrastername)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180273#M13853</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2021-12-11T09:13:13Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180274#M13854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The answers above don't take case into account, which is the variation that you mentioned. &lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good catch, although I didn't get that from the OP.&amp;nbsp; But yep case will need to be handled if it is important to the implementation.&amp;nbsp; One minor change could be made using:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

if ras.endswith("_pa") or ras.endswith("_PA"):

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180274#M13854</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T09:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180275#M13855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yeah that would work.&amp;nbsp; Usually I use the following format in order to reduce indentation:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
for ras in arcpy.ListRasters:
&amp;nbsp;&amp;nbsp;&amp;nbsp; if not ras.lower().endswith("_pa"):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; continue
&amp;nbsp;&amp;nbsp;&amp;nbsp; #now you are working with the correct raster, and you can do what you need
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.Rename(ras,"PA_" + ras[:-3])
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Though it may be tricky to get all of the auxiliary files if you are using os.rename(), right?&amp;nbsp; I assume that it's not just "raster.tif", but also "raster.tif.xml" and "raster.tfw", or .jpg, etc.&amp;nbsp; If you use the arcpy function, it'll rename all of the associated files at once.&amp;nbsp; Also, if the rasters are stored in a fGDB or something, I don't there's anyway you'd be able to access them with the os module.&amp;nbsp; It all depends on how/where they are stored.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180275#M13855</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T09:13:21Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180276#M13856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If you're importing os anyway, you can also use os.rename() rather than copying the raster. Rest is what James &amp;amp; Adam wrote about getting the name correctly.&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;os.rename() failed on a GDB raster.&amp;nbsp; But I also tried&amp;nbsp; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.Rename_management(ras, newrastername)&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but it failed with a "table already exists" error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 14:19:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180276#M13856</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-05-29T14:19:28Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180277#M13857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Though it may be tricky to get all of the auxiliary files if you are using os.rename(), right?&amp;nbsp; I assume that it's not just "raster.tif", but also "raster.tif.xml" and "raster.tfw", or .jpg, etc.&amp;nbsp; If you use the arcpy function, it'll rename all of the associated files at once.&amp;nbsp; Also, if the rasters are stored in a fGDB or something, I don't there's anyway you'd be able to access them with the os module.&amp;nbsp; It all depends on how/where they are stored.&lt;BR /&gt;&lt;BR /&gt;I've never used it before, but the Rename function that I linked to above looks super useful.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may be right. I've used os.rename on rasters, but using os.listdir(). Rename in your link does look promising.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 14:19:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180277#M13857</guid>
      <dc:creator>Zeke</dc:creator>
      <dc:date>2014-05-29T14:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180278#M13858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;but it failed with a "table already exists" error.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sounds like the newrastername already exists in the GDB?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would do a little inspection of the contents of the GDB, but if you need to remove something before proceeding, this is a useful construction:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
if arcpy.Exists(newrastername):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.Delete(newrastername)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just be sure to back everything up ahead of time!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 09:13:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180278#M13858</guid>
      <dc:creator>AdamCox1</dc:creator>
      <dc:date>2021-12-11T09:13:23Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180279#M13859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Sounds like the newrastername already exists in the GDB?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something was going on in the .gdb I guess, it was weird.&amp;nbsp; After a quick restart the arcpy.Rename_management seems to work.&amp;nbsp; This def looks like a really useful method!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 May 2014 14:32:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180279#M13859</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2014-05-29T14:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180280#M13860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used your code for the same application. the code runs fine and won't give me any issues. However I can't find the new rasters. Is there any way we can save the new rasters in a different folder?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My files are like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;20190512_160716_104b_3B_AnalyticMS_SR_clip&lt;/P&gt;&lt;P&gt;20190512_160717_104b_3B_AnalyticMS_SR_clip&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is the code I used&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy &lt;BR /&gt;import os &lt;BR /&gt;dir = r'D:\My_Canola_Project\1 New Process\Testing 5 Images' &lt;BR /&gt;arcpy.env.workspace = dir &lt;BR /&gt; &lt;BR /&gt;for ras in arcpy.ListRasters("*_clip"): &lt;BR /&gt; print (ras)&amp;nbsp;&lt;BR /&gt; basename = ras.split("_clip")[0]&amp;nbsp;&lt;BR /&gt; newrastername = "I_" + basename &lt;BR /&gt; print (newrastername ) &lt;BR /&gt; arcpy.Rename_management(ras, newrastername)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in Advance&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Nov 2020 21:55:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/180280#M13860</guid>
      <dc:creator>hansaneefernando</dc:creator>
      <dc:date>2020-11-06T21:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: Removing characters from rasters and putting them to the front of file name</title>
      <link>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/1026698#M59958</link>
      <description>&lt;P&gt;What would be the syntax if you just wanted to remove the first X amount of character from the current file name?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 14 Feb 2021 20:34:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/removing-characters-from-rasters-and-putting-them/m-p/1026698#M59958</guid>
      <dc:creator>MichaelTomiak</dc:creator>
      <dc:date>2021-02-14T20:34:22Z</dc:date>
    </item>
  </channel>
</rss>

