Since i’m quite new to applescript, this might be an easy one…i hope…
I have a file on the desktop that i want to delete. But the problem is that this script should work on any machine. So i need to use dynamic file paths. This is what i got:
tell application "Finder"
set file_path to ((path to desktop folder) & "invoice.pdf")
delete...
end tell
So i have the file path (altough…I think) , but what do i type next to the delete step?
Can’t get it right…
The ‘delete’ command requires an alias, or file specification to identify what item(s) to delete.
Your first line (set file_path to…) creates a string defining the path to the file in question (e.g. “Macintosh HD: Desktop:invoice.pdf”), so you need to convert (or “coerce”) this string to a file.
This is easily done by tell applescript to interpret file_path as a file: