Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

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

Recommended Posts

Posted

I am playing with the Document Tracker sample database from FM7. Each record has a container field with a link to a document. If I decide I no longer require a document I would like to be able to delete the target document from my hard disk as well as deleting the record from the Filemaker database. Is it possible to do this using a script? I can produce the Windows filename (including path) as a field fairly easily and I have tried using the DOS command Del in various ways with no success.

Posted

You would have to use the script step Send Event to call a batch file (e.g., filedelete.bat) which would have the line: delete %1 (where %1 is a variable batch parameter). The Send Event step would be something like:

"d:/filemake/filedelete.bat" & " " & Calctest2::container_name

where, obviously, you would substitute your path to the batch file, and substitute your table::field_name which contains the file reference.

Posted

as a side note, you don't need a batch file for a one-line command (or even a couple of lines). I've explained the whole thing in one of the FileMaker Advisor magazines last year.

Still using the Send Message/Send Event script step you can send it the following string (that you can calculate in a field if necessary to make it dynamic):

cmd /c del c:myFoldermyFile.ext

If you need more than one command executed, separate them with '&&' and they will execute sequentially.

'cmd /c' invokes the Windows Command interpreter (the black dos box) and asks it to quit when it's done ('/c').

This makes deployment a lot easier since you don't have to rely on the batch file being there.

Posted

I like the idea that the solution is self-contained so I tried this method. I had one or two problems. To check these out I removed the /c and replaced it with /k which keeps the window open to see what is happening. It seems that the part of the command following the /c (or /k) needed to be enclosed in "" and to get this into a calculation field requires the use of " for each " mark that you need, I then discovered, by accident, that system files seem to resist deletion by this method. But the strangest problem was that if I made a copy of a file with the usual "Copy of" prefix in the same directory, put this into my database then the script deleted the original file! What is going on here?

Finally I would appreciate a reference to your original article in Filemaker Adviser if it is available

This topic is 7369 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.