Is it possible to extract information from a raster file name?

1029
4
07-31-2014 01:38 PM
ShikoNjuno
Occasional Contributor

I have relevant information in my file name and I've already extracted the information I need from the raster itself  but I also need information that's in the file name. I know it may sound strange, but that's what I'm wondering if it is possible.

For example, if my file name is blahblahJune2010.tif.......is it possible to extract June2010?

Any suggestions welcome.

Thanks

0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus

if blahblah and *.tif were consistent, then you could easily parse that data off using python etc.  If this is a one-off event, and the number of files is relatively small, then spending time programming a solution wouldn't be worth the effort.

Addendum

You might want to use the convention of creating filenames that may contain pertinent information so that they can be parsed...for example

blahblah_June2014.tif (python example in verbose form and totally untested since I haven't got python on this friggin' iPad toy)

>>> a = "blahblah_June2014.tif"

>>> b = a.replace(".tif", "")

>>> c = b.split("_")[-1]

0 Kudos
ShikoNjuno
Occasional Contributor

Thanks Dan,

What do you mean by consistent?

And yes, I don't have the time to create any kind of code to do this.....mostly because I don't know how to write code. So I was hoping that there's some kind of tool I could pull into ModelBuilder to perform this operation.

Any other suggestions.

0 Kudos
DanPatterson_Retired
MVP Emeritus

see above, I was updating the thread as you posted...sorry

0 Kudos
ShikoNjuno
Occasional Contributor

Great! I found some info on the help guide regarding "parse path" on Model Builder.

I'll look into this.

Thanks

0 Kudos