Jump 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.

Filemaker variable in applescript

Featured Replies

Hi, I need help...

I have this applescript in a calculated field in filemaker:

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

delete file \"Snow Leopard:Users:ton:Desktop:blabla:blaimport.txt" &"\" ¶

end tell"

What is the syntax to replace this file path with a fieldvalue or filemaker variabele???

Depends on the context, but in a script for example:

Set Variable( $path ; "Snow Leopard:Users:ton:Desktop:blabla:blaimport.txt" )

Set Variable( $x ;

"tell application \"Finder\"¶

delete file " &

"\"" & $path & "\"¶

end tell" )

Perform AppleScript ( $x )

  • Author

Depends on the context, but in a script for example:

Set Variable( $path ; "Snow Leopard:Users:ton:Desktop:blabla:blaimport.txt" )

Set Variable( $x ;

"tell application \"Finder\"¶

delete file " &

"\"" & $path & "\"¶

end tell" )

Perform AppleScript ( $x )

Thank you for your fast reaction!

All I want is to delete a file in the same folder as the application.

The path is in a calculated field in FM (path with colon's replaced for slashes), I want to use that value in a script to delete the file.

The path has to be calculated because it is not always the same.

When I paste your example in a calculated FM field I cannot save the field because of errors.

I also have this script:

set x to POSIX file ((POSIX path of (path to me)) & "/..") as text

set x to x & "blaimport.csv"

tell application "Finder"

delete the x

end tell

This worked for me but only as a standalone applescript and not from FM.

It might help to know what version of FileMaker you're running. It's a good idea to set that in your profile.

If you really want to use the FileMaker folder, you can use the Get(FileMakerPath) function.

Other functions you may be interested in:

Get(FilePath)

Get(DesktopPath)

Get(DocumentsPath)

Get(TemporaryPath)

I'm not sure why you want to use a calculated field for this, since it's going to be scripted anyway, but you could for example have this in your field:

"tell application \"Finder\"¶

delete file "\<<xyz>>"\¶

end tell"

Your script could then be:

Set Variable( $path ; Get(FileMakerPath) & "blaimport.txt" // or whatever you're using to get the file path )

Set Variable( $x ; Substitute( yourApplescriptCalcField ; "<<xyz>>" ; $path ) )

Perform AppleScript ( $x )

  • Author

I still cannot get it to work...

I think i getting confused by Applescript and Filemakerscript.

I simply want (from Filemaker pro advanced 11) to delete a file on the desktop (changed my first plan) because the path to the desktop is not always the same filemaker has to deliver the path.

The following in a in a filemakerfiled, (your example):

"tell application \"Finder\"¶

delete file "\<<xyz>>"\¶

end tell"

How do I get the path and filename in <<xyz>> ??????

BTW, when I paste your example script "set Variable and so on I cannot save that script (applescript refuse to save because of a error)

If you have a field named "Filename" in a table named "YourTable", you can simply call the Perform AppleScript[] script step, with the following calculated AppleScript =


"tell application \"Finder\"¶

delete file " & Quote ( YourTable::Filename ) & " of (path to desktop)¶

end tell"

delete file "\<<xyz>>"\¶

That was a typo, should be: delete file \"<<xyz>>\"¶

(with the backslashes before the quotes)

How do I get the path and filename in <<xyz>> ??????

Did you look at the two scripts I posted? The Set Variable steps?

Look, if you really want the whole script to show up in a calculated field, try this:

"tell application \"Finder\"¶

delete file \"" &



Let( [ 

   path = Get ( DesktopPath )  ;                    /* or use  Get ( FileMakerPath ) or whatever you need here*/

   pathTrim = Replace ( path  ; 1 ; 1 ; "" ) ;      /* gets rid of the leading slash */

   pathMac = Substitute ( pathTrim ; "/" ; ":" ) ;  /* applescript-friendly path */



result = pathMac & yourTable::yourFileName

      ]  ;



result   )



& "\"¶end tell"

The calc uses a field called yourFileName in a table called yourTable. I tested this and it works. (I was on a PC for the previous posts and could not test, sorry for any errors.)

  • Author

If you have a field named "Filename" in a table named "YourTable", you can simply call the Perform AppleScript[] script step, with the following calculated AppleScript =


"tell application \"Finder\"¶

delete file " & Quote ( YourTable::Filename ) & " of (path to desktop)¶

end tell"

This simple solution works for me....

Thanks again.

Now only have to find the same trick for delete a file from Windows, is this a topic for this forum?

Is

  • Author

That was a typo, should be: delete file \"<<xyz>>\"¶

(with the backslashes before the quotes)

Did you look at the two scripts I posted? The Set Variable steps?

Look, if you really want the whole script to show up in a calculated field, try this:

"tell application \"Finder\"¶

delete file \"" &



Let( [ 

   path = Get ( DesktopPath )  ;                    /* or use  Get ( FileMakerPath ) or whatever you need here*/

   pathTrim = Replace ( path  ; 1 ; 1 ; "" ) ;      /* gets rid of the leading slash */

   pathMac = Substitute ( pathTrim ; "/" ; ":" ) ;  /* applescript-friendly path */



result = pathMac & yourTable::yourFileName

      ]  ;



result   )



& "\"¶end tell"

The calc uses a field called yourFileName in a table called yourTable. I tested this and it works. (I was on a PC for the previous posts and could not test, sorry for any errors.)

I used the above example:

"tell application \"Finder\"¶

delete file " & Quote ( YourTable::Filename ) & " of (path to desktop)¶

end tell"

This works for me, is your example better???

The way to get the pathname is a lot different your way, is there a reason for???

If your file is always on the desktop then Applescript gives you an easy way to do that. If you want to use other paths, you may need a different method. I'm glad you found a solution that works for you.

Create an account or sign in to comment

Important Information

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

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.