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.

Featured Replies

  • Newbies

I need to import a number of files into fielmaker. Can I 'write' a file reference to an filemaker import script? If not can I use applescript to repeat through the files and import them one by one?

Thanks

You can use a Script Variable in FileMaker 8, and that can be used in an Import file reference as either a relative path, or a full file path.

(relative file path)

file:$variable name

or

(full file path)

filemac:$variable name

The Script Variable above would be set to a FileMaker syntax path (not AppleScript or Unix paths, ie. no ":", no "~"). There is a Get(DesktopPath) function also, which helps here. So if upgrading is possible, that's the way to go.

Otherwise, in earlier FileMaker versions, you need to use another tool to deal with the files. AppleScript can do it fairly easily, but it's way more work than the above. Actually, even in FileMaker 8 you'd want to use AppleScript to get a folder listing, of files in the folder. Here's an AppleScript I just wrote, which will get the files of the chosen folder as a return-delimited FileMaker syntax, which can then be parsed line by line into a dynamic Script Variable.

tell application "Finder"

set theFiles to every file of (choose folder) as alias list

set txtLines to my makeReturns(theFiles)

set thePaths to my FM_paths(txtLines)

end tell

on makeReturns(a)

set AppleScript's text item delimiters to {ASCII character 13}

set theLines to a as text

set AppleScript's text item delimiters to {""}

return theLines

end makeReturns

on FM_paths(:

set AppleScript's text item delimiters to ":"

set FM_line to b's text items

set AppleScript's text item delimiters to {"/"}

set FM_lines to FM_line as text

set AppleScript's text item delimiters to {""}

return FM_lines

end FM_paths

Otherwise, in FileMaker, you have to use a "switcheroo" method. Because you can only Import a fixed file path, you have to rename each file to that file path, then Import, then rename/move it back, then do the next. I have example files doing this. But what kind of files are you importing? There is also a method to just "read" the file, which works well for .tab or .csv files. For just text files you would use the Import Folder step instead; all the text into 1 field.

  • Author
  • Newbies

Thanks Fenton, invaluable info.

The files a .csv. You said

"There is also a method to just "read" the file, which works well for .tab or .csv files."

Could you run that pass me?

Many Thanks

This is an example file which reads csv files. Hopefully works for you. It has only been tested on small files.

csv_Import_Read_Text.zip

  • 3 weeks later...

I just wrote this one to do something very similar. It takes .txt files one by one from and "in folder", imports the data, then moves the file to a "done folder".

I chose Fenton's "switcheroo" method, and it works pretty well, but I could use some help error-proofing it.

I put in the "delay 10" because I didn't know how to have Filemaker Pro signal Applescript it was ready to go to the next step. If I didn't have a delay then the script could/would rename the file before Filemaker was finished importing the data, and that would screw everthing up.

I'm afraid that the case may come up where a delay 10 is not enough (large import file), but don't want to delay longer just for that rare occasion.

Anyone have something with more finesse?

Thanks, JA

(sorry it's got info in it that hardwires it to my machine)

--

set importFolder to "Macintosh HD:Users:jamcrae:Desktop:watched folder:New Manifests:" as alias

set doneFolder to "Macintosh HD:Users:jamcrae:Desktop:watched folder:Imported Manifests:" as alias

set picFolder to importFolder as string

set picList to list folder picFolder without invisibles

tell application "Finder"

activate

repeat with eachFile in picList

set name of document file eachFile of folder picFolder to "ImportMeNext.txt"

tell application "FileMaker Pro"

activate

do script "Import Script"

end tell

delay 10

tell application "Finder"

activate

set name of document file "ImportMeNext.txt" of folder picFolder to eachFile

move document file eachFile of folder picFolder to folder doneFolder

end tell

end repeat

end tell

  • 8 years later...
  • Newbies

Hi guys,

 

I'm sorry to re-new this old thread, but I have a similar problem and maybe some of you could help me ;-)

 

I have to import a lot of excel files (nearly 250 tables), each of them with its own header (table structure). The FM wizard let me import only one table, so I tried to use your scripts above with some changes. But I think the problem is to create the FM script to do this job. I created a FM script with the wizard but I don't know how to change the variable table name for creating in FM.

 

It would be nice if someone have a short hint.

 

Thanks.

  • Newbies

Hi,

 

I managed the import using "TableClipper" - worked ;-)

 

Thanks.

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.