Change Directory and Name of reference to a file

I’m trying to write my first AppleScript, and I’m just not finding what I need in the tutorials.

The task is pretty simple: it just needs to (1) accept an argument containing a file name (from FileMaker), (2) change to the appropriate directory, and then (3) rename a file to match the argument.

Here was my first take at it. I reckon I need to use objects here rather than text strings.

tell application “Finder”
set currentFolder to “/Users/me/Documents/TestStuff”
set name of file “temp_name.pdf” to “better_name.pdf”
end tell

(FWIW, written in shell script, this is what I need to do:
cd ~/Documents/TestStuff; mv temp_doc.pdf $*)
:?:

Does this work?

set currentFolder to ("/Users/me/Documents/TestStuff" as POSIX file) as text
tell application "Finder"
	set name of file "temp_name.pdf" of folder currentFolder to "better_name.pdf"
end tell

– Rob

Yes it did – thanks for the help. This is the script I’ve ended up with:

tell application “FileMaker Pro”
set myvar to field “_gFileName”
end tell

tell application “Finder”
set currentFolder to (“/Users/me/Documents/TestStuff” as POSIX file) as text
set name of file “temp_doc.pdf” of folder currentFolder to item 1 of myvar
end tell

Glad to help. Why are you referring to ‘item 1 of myvar’? Does this not work?

tell application "FileMaker Pro" to set myvar to field "_gFileName"
set currentFolder to ("/Users/me/Documents/TestStuff" as POSIX file) as text
tell application "Finder" to set name of file "temp_doc.pdf" of folder currentFolder to myvar

– Rob