Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Automatically Delete file via applescript

Featured Replies

Please help.

I am trying to delete a file via an automated script, and my IT guys want me to do it via applescript as opposed to buying a plugin. When we run the applescript outside of filemaker it seems to work... for instance when we run the below script in the terminal window on my mac, it works, but when we try and pass that through the applescript command in FM it doesn't do anything.

here is the syntax... what are we doing wrong. ? This comes from a formula he used trying to get the same format as in the terminal window.

"tell application \"Finder\"" & ¶ &

"delete file " & Quote($as_command) & ¶ &

"end tell"

$as_command = posix path = /Volumes/Show/Elements/Segments/...

The other command I've tried is

"try" &¶ &

"do shell script \"rm " & Quote($as_command) & "\"" &

"end try"

You cannot use a POSIX path as such in Applescript. Try something like:

delete POSIX file & Quote ( $yourPosixPath )

Re your other attempt, you cannot use double quotes within double quotes; put the filepath in single quotes.

  • Author

Thanks for the help, I'm not getting it. I have this in my applescript editor to make it work there, and it errors on the first ( and tell me it's expecting an end of line there.

tell application "finder"

delete POSIX file & Quote ( /Volumes/Macintosh HD/User/Administrator/Desktop/test.txt )

end tell

Well, Quote() is a Filemaker function - you can't use it in AppleScript Editor. The thing is you eventually want to get:

tell application "Finder"

delete POSIX file "/Volumes/Macintosh HD/User/Administrator/Desktop/test.txt"

end tell

so if you are using a calculated AppleScript, your calculation (i.e. your Filemaker calculation) must return exactly the text above. If your POSIX path is stored in a $path variable, you could use:

"tell application \"Finder\"" & ¶ &

"delete POSIX file " & Quote ($path) & ¶ &

"end tell"

as the formula.

  • Author

Thanks for publishing the full script... it's really helpful. I will give it a bash in a week after my final week off. Thanks for support... it's great.

s

  • Author

Don't know if anyone can still help me... but,

I heard back from my IT guy. He is a real filemaker wiz, and he's tried what was suggested here, and can't get it to work. Is it possible there is a differernt syntax for a volume mounted via the network? I believe it is connected via afp - (or possibly smb), and the syntax in this thread simply isn't working.

Any other suggestions are most welcome!

Steve.

Can he make it work in AppleScript Editor?

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.