Return partial file path in dynamic text

2951
3
07-21-2015 10:29 PM
MarkFawkes
Occasional Contributor

Investigating some automation of our maps and want to put the mxd file location on the map. All our mxds are stored in folder (+/- subfolders) with the folders 5 deep in the file path e.g. mxd might be in 

G:\aaaa\bbbb\cccc\dddd\eeee\BASE_FOLDER\SUBFOLDER\mxd_name

where there will always be the BASE_FOLDER which is a project identifier - the SUBFOLDER part might exist for a major project but not for all projects. I can insert the full path as dynamic text, but would prefer to NOT SHOW the part G:\aaaa\bbbb\cccc\dddd\eeee\. There will always be the same number of nested folders.

Can anyone offer any solutions (even if it is a hack).

0 Kudos
3 Replies
NeilAyres
MVP Frequent Contributor

Not sure if this will help in your context but with python you could use the split & join methods...

pth = "c:/aaaa/bbbb/cccc/Project_X/SubFolderY/Some.mxd"
>>> mxdId = pth.split("/")
>>> mxdId
['c:', 'aaaa', 'bbbb', 'cccc', 'Project_X', 'SubFolderY', 'Some.mxd']
>>> mxdId[-3:]
['Project_X', 'SubFolderY', 'Some.mxd']
>>> mxdIdSub = "/".join(mxdId[-3:])
>>> mxdIdSub
'Project_X/SubFolderY/Some.mxd'
>>>

You would have to provide some other logic to identify where you need only the last 2 parts (no sub folder).

0 Kudos
MarkFawkes
Occasional Contributor

Thanks Neil

Took the easy way out and have decided to change our mxd naming convention to include the info I wanted. Easier to use dynamic text to just add the mxd name than try and parse the file path.

0 Kudos
AmyGwin2
New Contributor III

This is a serious need for us. We generate so many maps, and need to quickly find the maps from [last year, last quarter] to make the exact same map again with one change in less than one hour..... so the dynamic text is crucial to our productivity and turnaround time. Can a custom dynamic text code be used in our organization ?? Is this possible?

Can the default folder dynamic text be forced to return just the left 75 characters? 

Kudos to anyone who can solve this! 

dynamic text format‌ arcpro template customization ArcGIS Pro

0 Kudos