Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Does anybody know how to add the shape file name to a field in the file's attribute table? I've found a description:

'You have to use inline variable in CalculateField like %Name% in expresssion so that whatever the name of the file is, the string will be inserted based on Name of the dbase file !'

I've tried to CalculateField tool with %Name%, but I got message:

Executing: CalculateField "2011-11-6 15_41_point" DBFName %Name% PYTHON #
Start Time: Thu Dec 08 23:34:23 2011
WARNING 000405: No records within table
Succeeded at Thu Dec 08 23:34:24 2011 (Elapsed Time: 1.00 seconds)

Where is my mistake?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

There is a script on the arcscripts website that should assist you in doing this


Summary A simple script for creating a field called "FILENAME" and attaching the filename of the shapefile to each entry in the attribute table. Use with as many shapefiles within a specified directory. Useful when picking apart shapefile entries and combining into a separate file to maintain a breadcrumb trail of the original shapefile name.

Run file within a directory containing all the shapfiles needing modification

I hope that this's what you're after

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.