Hello,If you're creating the textfield filename, and trying to write text to it, I think I see the problem.For string literals, your expression value needs to be encapsulated by quotes when it's passed to the Field Calculator. Your code should therefore be:arcpy.CalculateField_management(fc, "filename", '"' + tmp2 + '"')
What you were passing to the expression field before was this:myfilename
whereas what you wanted to send, and what you'd see in the Field Calculator, is this:"myfilename"
Hope this helps!