I am working with Korean topo map layers. They are 1:1000 scale and divided by each map section.
they are also stored in different folder.
Since a layer shows road has same name (e.g., a0010000_polygon.shp), i added the district name as a prefix (e.g., 376120547_blah blah_..._a0010000_polygon.shp)
Here is the problem. now, i need to merge each layers that have same suffix (i.e., merging all layers that ends with a0010000_polygon.shp in each folder) to make one large big huge layer
What i did is, iterate thru all the folder and using wildcard and make feature layer (add to the TOC). Then, drag the layers to merge toolbox..
there are at least 180 layers in each folder, and doing 180 times of this is kinda crazy.
Are there better way to solve this issue?
I came up with this model ... (using collect value) but still i need to adjust wildcard to iterate thru layers have same suffix :(
Oct. 16, 2016 I add this comment
my final (?) model looks like this. (it ain't final until it really works) what i did is that i create a table that contains all possible layers (See 'library' field)
then i iterated thru the table row and get the row value and put that in my model.. so that it merges all layers that have same name
the problem is that the shape layers in a folder doesn't have all layers in the library table (e.g., the library has all possible layers, which is 108. but shape layers in a folder has only 40 or sometimes 60) and therefore, it returns merging error lol
so i was thinking about using try / except python script and put that in a model check this --> [http://resources.esri.com/help/9.3/arcgisdesktop/com/gp_toolref/automating_your_work_with_models/branching_colon_implementing_if_then_else_logic.htm][5]
spent almost a week to solve this issue with modelbuilder and it has some limit i think. I will come up with better idea if i can. (so far the best way / easiest way is insert arcpy script try/except) but if there is anybody who knows more precise and elegance way to solve this, please share with us.
after i tried 'dru87''s code, i finished the work. I typed line by line into the console and run and it only returned the last string in the list.
instead, you must copy and paste the entire code and run it (of course, you need to change the workspace and stringSearch)
awesome. and nice. still i have the modelbuilder here and i prefer modelbuilder because i suck at python and if anybody can improve the model, please let me know!