0
votes

I want to change a filename in the folder which is not always the same, it depends on where the applescript is stored (same folder as the file to change).

I made this script with a dialog to check the path, that works fine but after but I get an error (-1700, Can't change "test" into an integer. Why, and how do I fix this?

tell application "Finder"    
    set thePath to POSIX path of ((path to me as string) & "::")    
    display dialog thePath buttons {"Clipboard", "OK"} default button 2    
    if the button returned of the result is "Clipboard" then
        set the clipboard to thePath
    end if
    set name of document file "test" of thePath to "test_OLD"
end tell
2

2 Answers

2
votes

If you are using Finder, which you only need for the set name statement, you need to coerce thePath from a posix path to a hfs path.

You can also remove the entire Finder block and use:

tell application "System Events" to set name of file (thePath & "test") to "test2"
0
votes

Could this be an easier way syntax wise?

 tell application "System Events"
        set name of file "/Users/Firebird/Documents/test2.jpg" to "/Users/Firebird/Documents/11.jpg"
    end tell