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.

Importing file names from a folder

Featured Replies

I'm wondering if anyone has a script or an AppleScript that would allow me to import the name of every file in a set of folders into the database. I need to get the folder name and the file name within the folder.

Any suggestions are appreciatied. Thanks.

We use the Troi File plug-in for this and other purposes. It's also cross platform.

-bd

  • Author

Thanks. I was looking at this plugin and given my limited knowledge of this, how is it possible to have the plugin read in the file names one to a record? I noticed that in the example all the file names are read into a global field. I need to have each file in a separate record along with the folder name. Any clarification is appreciated.

The nature of all plugins is to deal with 1 field at a time because of the way FM designed the plugin interface. You'll need a simple script to parse the filenames and put them in their own records after the call to the Troi file plugin.

I agree that a plug-in is the way to go if you need this function as part of a solution that you will be distributing. But if you just need a one-off AppleScript to get initial values into your database, here's an adapted version of the Picture Import Applescript that comes with FileMaker:

--choose a folder with picture files

activate

set folderPath to (choose folder with prompt "Choose a folder with filenames to import

  • Author

Thanks! It works great.

One additional thing I am trying to figure out is how to set the Folder Name field in the database to the name of the folder that the file came from.

Ultimately the path created in a calculation will create a link to the FTP directory, but for this to work, I have to be able to get the folder name for the path string. Any ideas? Thanks again.

skuli

The folderPath variable in the AppleScript holds the path to the file. You could extract the folder name from that. Define a field in your database, say, File Path, and use:

set Cell "File Path" of newRecord to folderPath

immediately after the other set Cell command.

  • Author

Thanks Peter. This works although "as string" needed to be added to the set cell line. Works like a charm.

Skuli

Glad to hear it works for you, and thanks for the clarification.

  • Author

No problem.

Can you also give some direction on how I would modify this script to read the contents of folders within the selected folder?

I have an idea that there has to be some sort of if statement to the effect of "if folder count is greater than 0", but I'm not sure. This is almost there.

Bradley

This will require a bit of recursive scripting -- let me think about it a bit, and welcome other AppleScript experts' opinions. The Troi File plug-in seems more and more like a better option! smile.gif

  • 1 month later...

I know you got all these answers and have probably already come up with a solution. I used to use applescript to complete this task, till I ran into the following simple and fast tecnique. All you have to do is open the folder, view by list, select all, copy and paste into a text editor. Save out that file and do a file/import into Filemaker and VOILA you got all the file names into a database. Of course you are limited to the amount of files one folder can see at a time (not sure of the exact amount - I just never go over 1000 at a time). It requires some intervention and/or you could write an applescript that does that function. I just find it ALOT faster than the applescript.

  • 8 months later...

I know this post was a long time ago, but I was trying to figure out how to do this and came up with a solution.. which is SOOOOOOOO SIMPLE.

All you need to do is go to a dos prompt and do the following at the desired location:

dir /b > C:filename.txt

This will create a text file at c:filename.txt (or wherever you like) with a list of all the files which you can then import into Filemaker. Then on the group import just do a field replace with the foldername.

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.