Select to view content in your preferred language

Parts ofa file name to become a field string.

1033
4
06-02-2012 12:16 AM
PatrickFischer1
Deactivated User
Hello everyone,

I have a script that takes an MXD and makes a polygon of the outline of the Main Dataframe and has some metadata added to the fields. All of my MXD's have a product ID as their file name. I also have a field named product ID. Is there a way to make the string that is calculated into my Product ID field be populated by the name of the MXD? Is there also a way to take out certain parts of a file name, as my Product ID has other information such as Area Covered, Product Type, Edition, ETC?
Tags (2)
0 Kudos
4 Replies
NobbirAhmed
Esri Regular Contributor
Try Calculate Field gp tool. Extract the product ID from map document's name and set it to the ProductID field. Follow this topic if you need help:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Calculate_Field/00170000004m000000/
0 Kudos
PatrickFischer1
Deactivated User
I tried that. However i also have an export of my product in the same folder as a pdf for dissemination purposes. When i ran the split text it gives me both then i added *.mxd and it would always return an error for me when trying to use it as a label. Do i need to turn it into a string via GetParameter?
0 Kudos
MarcinGasior
Frequent Contributor
Here's an example how you can put ArcMap project filename into attribute value.
In Field Calculator Pre-Logic Scrip Code:
def projName():
  import os
  mxdPath = arcpy.mapping.MapDocument("CURRENT").filePath
  filePath, fileExt = os.path.splitext(mxdPath)
  fileName = os.path.basename(filePath)
  return fileName


ProjName =
projName()
[ATTACH=CONFIG]15649[/ATTACH]

If you want to do this in standalone script use arcpy.CalculateField_management() to calculate field values.
0 Kudos
PatrickFischer1
Deactivated User
sorry i should have clarified. I'm trying to run this through arc catalog rather than arcmap. The end state of this is a custom tool for the ArcToolBox. Any ideas on that?