1 Reply Latest reply on Aug 26, 2010 1:02 PM by FentonJones

    Help with task probably using Applescript?



      Help with task probably using Applescript?


      I have not really worked with applescript but I believe its probably involved. I have a script that goes to my browser downloads an excel document into the downloads folder and imports it into to filemaker. I need help on how to trash the downloaded file? My import is a daily routine so I always need to delete the old file before the new one can be imported.

      Thanks for help.

        • 1. Re: Help with task probably using Applescript?

          Yes, AppleScript could do this. You haven't said much about how you target the file for Import into FileMaker. But since it seems you are doing that via  a script, then you must have the FileMaker syntax file path. (Or do you choose the file manually during the Import script step?)

          There are 2 ways to "delete" a file via AppleScript. You can either delete it immediately, using the Unix 'rm' command line. But that's a bit dangerous, as there's no way to recover from a mistake (oops! forgot the file name, and removed the whole downloads folder!).

          The safest method is to let the "Finder" put it in the trash can. 

          tell application "Finder" to delete alias "mac file path"

          "mac file path" looks like "Macintosh HD:Users:fej:Downloads:DSC_4382.jpg"

          FileMaker syntax path looks like: "filemac:/Macintosh HD/Users/fej/Downloads/DSC_4382.jpg"

          A calculation which works for either inserted images or files, to produce a Mac file path ( fm_path being the FileMaker syntax path):

          Substitute ( fm_path; ["imagemac:/"; ""]; ["filemac:/"; ""]; ["/"; ":"] )