This Site Powered by FileMaker and FX.php 
FMWebschoolFMWebschool Site MapFMWebschool Site Map
FileMaker Web DevelopmentFileMaker buttonsFileMaker plug-insFMWebschool VideosFMWebschool productsFMWebschool FileMaker servicesFMWebschool FileMaker specialsFileMaker ResourcesFMWebschool forum

FMWebschool

FileMaker Command Line Scripting

April 24th, 2007 by Stephen K. Knight

FileMaker Command Line Scripting

 

This is the first in a series of articles discussing FileMaker command line scripting. This article was written for Windows. By using Applescript on the Macintosh, you can replicate all of the examples shown below.

 

 

*A sample FileMaker database is included with all of the examples discussed below*

 

I will cover the following command line scripts:

 

· Create a folder

· Delete a folder

· Rename a folder

· Delete a file

· Rename a file in a directory

· Move a file from one folder (directory) to another and rename that file

 

Example 1. Creating a folder
In the first example, I will create a folder on the “C” drive. The folder will be named “fmscripting”.

 

1. Open FileMaker and create a new script. Name the script “Create a folder”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code without the quotes.
“
cmd.exe /C MD C:\fmscripting” the spacing must stay the same as listed.

5. Uncheck the box that says “bring target application to foreground.

That’s it. Now run the script. Check your “c” drive, you should have a new folder named “fmscripting” on your “C” drive. The location would look like this C:\fmscripting.

 

Example 2. Delete a folder

In the first example, I will delete the folder that you just created

 

1. Open FileMaker and create a new script. Name the script “Delete a folder”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code without the quotes.
”
cmd.exe /C RD C:\fmscripting”

5. This will delete the folder that you just created

 

Example 3. Rename a folder

Run the Script “Create a folder” This will create the “fmscripting” folder on your “C” drive again. The code that we will write next, will rename the folder you just created to “happiness”.

 

1. Open FileMaker and create a new script. Name the script “rename” folder”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code without the quotes.
”
cmd.exe /C REN C:\fmscripting happiness”

5. Open your “C” drive, you will now see that the “fmscripting” folder has been renamed to “happiness”.

Example 4. Delete a file

In this next example, create a text file on your “C” drive and name it “Apple.txt”. The file path would look like: C:\Apple.txt

 

1. Open FileMaker and create a new script. Name the script “Delete a folder”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code without the quotes.
”cmd.exe /C del c:\Apple.txt”

5. Open your “C” drive, you will now see that the text document “Apple.txt” has been deleted.

 

Example 5. Rename a file in a folder/directory

For this example, create a folder named “holding” and then create a Text document and name it “example.txt” and place it in “holding”. So it would look like this: C:\holding\example.txt

This example will rename that file to “finished.txt”.

 

1. Open FileMaker and create a new script. Name the script “Rename File”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code without the quotes.
”
cmd.exe /C REN C:\holding\example.txt finished.txt”

Open your folder named “holding” the text file should now be named “finished.txt”.

 

Example 6. Move a file from one folder (directory) to another and rename that file

For this example, you will need to create a folder named “myfolder” and place it on your C drive. This script will then copy “finished.txt” from “holding” and paste it in myfolder, and rename it “new.txt”.

 

1. Open FileMaker and create a new script. Name the script “Rename File”

2. Under Miscellaneous in the script selection – select “Send Event”

3. The “Send Event Options” window will open. Select Text.

4. In the text box, type the following line of code WITH QUOTES as displayed
cmd.exe /C COPY C:\holding\finished.txt “C:\myfolder\new.txt”

I hope that you find these scripts helpful! If you have any cool FileMaker command line tips, please add them to this blog.

Leave a Reply

Site Design by FMWebschool - Copyright © FMWebschool 2005 - Powered by FX.php and FileMaker
FileMaker and the FileMaker logo are registered trademarks of FileMaker, Inc
All other trademarks and copyrights are the property of their respective owners.