renaming problems

I have created a renaming script that works just fine if the folder containing the file to be renamed is open on my desktop, but fails if the folder is closed and several levels deep.
This is what I am using:

A typical filepath looks like

set AppleScript's text item delimiters to {":"}
					set argCnt to (the count of text items in FilePath)
					set ServerName to (text item 3 in (FilePath)) as string
					set VolumeName to (text item 4 in (FilePath)) as string
					set newFilePath to (text items 4 through argCnt in (FilePath)) as string

         --some steps here to get NewFileName
          set name of file newFilePath to NewFileName

Thanks for any ideas about what I might be doing wrong.

i can’t quite wrap my head around your script, so i don’t know if this would be of any help, but it seems like sigma’s coercions would be helpful for you. it has an item name/container name command that may be just the thing you’re looking for.