Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4941 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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???

Posted

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 )

Posted

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.

Posted

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 )

Posted

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)

Posted

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"

Posted

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

Posted

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

Posted

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???

Posted

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.

This topic is 4941 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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