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.

Using Send Message to delete a file

Featured Replies

I know this has to be here, somewhere, but I can't find it!

Can someone please give me the correct syntax for Send Message to delete a windows file? I have a script that imports data from an excel file into my FMP6 app, and I want the script to delete the excel source file after the import.

Also need the same for Apple Send Event command.

Thanks.

Ellen,

Try this:

SendMessage ["aevt","odoc","cmd /c del c:folderfolderfile.ext"]

Maybe sombody else can "weigh-in" on the Mac commands. I haven't touched an Apple machine in over 10 years.

On Mac:

Perform AppleScript [ text below ]

tell application "Finder"

delete file "complete file path"

end tell

If you don't know the complete file path on each user's machine, it can be put together, either by AppleScript:

set theDesktop to (path to desktop as string)

-- the above cannot be inside the Finder block

set theFilePath to theDesktop & "folder path (if any):file.xls"

tell application "Finder"

delete file theFilePath

end tell

Or by combining the file's relative location to the current database file; whose folder path, as a FileMaker Unstored calculation, is (on a Mac):

Substitute( Left(Get(FilePath); Position(Get(FilePath); "/"; 1; PatternCount(Get(FilePath); "/"))); ["/"; ":"]; ["file::"; ""] )

  • Author

Thank you for the quick responses!

You might want to consider a file plugin, which will give you a lot more functionality. Look at Troi, and a free one at David McKee's site Protolight

Steve

If you are more comfortable with UNIX/DOS style commands than Applescript, you can accomplish the same thing on the Mac by using the "Send Event" script step to execute a shell script with the "Do Shell Script" Applescript command.

Now that I read that back to myself, it sounds kind of complex, but it is really easy...

Just paste this into the "Calculated Applescript" dialog in the Perform Applescript script step:

"do shell script "rm -f /myFolder/myFile.txt""

Where "myFolder" is a folder at the top level of the hard drive (Macintosh HD, or whatever) and "myFile" is the file to delete.

If that is confusing, work backwards...

You would type this into the Terminal to accomplish the task:

rm -f /folder/folder/asdf.txt

Therefore, you would type this into the Applescript Script Editor application (not FileMaker)...

do shell script "rm -f /folder/folder/asdf.txt"

So, to make that fly in a FileMaker calulation dialog, you have to quote the whole thing and escape the existing quotes...

"do shell script "rm -f /myFolder/myFile.txt""

Once you get your head around it, you will find youself using the same concept for all kinds of file management...

HTH,

j

  • 1 year later...

Picking up an old thread...

If you are more comfortable with UNIX/DOS style commands than Applescript, you can accomplish the same thing on the Mac by using the "Send Event" script step to execute a shell script with the "Do Shell Script" Applescript command.

I am a little confused here. Should one use the "Send Event" of "Perform AppleScript" ScriptMaker command?

However, neither is working for me.

Eg, I want to execute "top -u" in the Terminal, directly from Filemaker. I am using the "Perform AppleScript" script step and it goes like this:

tell application "Terminal"

	activate

	do shell script "top -u"

end tell

Terminal opens up right, but nothing is happening. What is wrong?

While we are on the subject; I'm wondering if it is possible to do the following (FM8.5, OS X):P

- Start a Filemaker script from the Terminal?

- Pass shell variables from the Terminal to scripts in Filemaker?

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.