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.

Browse for Folder, get list of files - VBscript [Finished-8 Advanced]

Featured Replies

Description: The demo file shows how to use VBscript to pop up a "browse for folder" OS dialog and return the path to the selected folder and a list of its files back to FileMaker.

Working Under: 8 Advanced

Solution Status: Finished

Pre-requisites: FileMaker 8

Author(s):) Wim Decorte

Date: 02/09/06

Credits:

Instructions / Other Info: It clearly shows the challenges of using VBscript with FileMaker on Windows:

- generating the VBscript syntax

- creating the VBscript file on the hard disk & executing it

- returning a result back to FM (using the import engine, but not creating any new records)

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

VBscript_folderContent.zip

Hi Wim,

Thanks very much for this example it is great! I haven't tested it as yet but it is a really helpful example for someone who is a mac specialist and now has to deal crossplatform.

Thanks again

Lance

Very good, thank you. Does anybody know applescript to make the same for mac?

It's fairly simple to get the list of files in AppleScript. But it depends what you want, and what you want to do with the results.

Just the names? (These can be added to the folder, to produce a full path.)

set theFiles to list folder (choose folder) without invisibles

An Applescript list of files (in Finder syntax):

tell application "Finder"

set theFiles to files of (choose folder)

end tell

Or, in alias syntax, which is much the same, but looks better:

tell application "Finder"

set theFiles to files of (choose folder) as alias list

end tell

Or you can get a list of the full paths in a return-separated list, which can then be set into a global field. That needs a little more work (I've commented out the FileMaker part, as you'd need the field):

tell application "Finder"

set theList to files of (choose folder)

set newList to (item 1 of theList as string)

repeat with i in theList

if i is not item 1 of theList then

set newList to newList & return & (i as string)

end if

end repeat

set newList to newList as string

end tell

(*

tell application "FileMaker Pro Advanced"

set cell "_gFiles" to newList

end tell

*)

This example file Inserts the files in a folder. It's 8-only.

Insert_Folder_Files.zip

Thank you so much, Now I have answer to some of my questions. And, VBScript with AppleScript can greatly extend FM possibility in both platforms!

  • Author

You bet!

  • 4 months later...

I am trying to figure out how to get this script into my database. Can someone help?

Seriously, this script looks like my best bet, but i do not know how to get this functionality into one of my databases... can someone walk me through it?

actually, although this is close, because this does store the path into a field, but this just scans a folder and dumps the contents of the entire folder. I would also need to be able to select a file, not just a folder, and have the path to the file be in one field and the file name you selected in another field.

any takers?

This was realy nice. I will use it for keeping track of my invoice copies stored on the harddisk.

Thanks.

Edited by Guest

  • 2 weeks later...
  • Author

Not sure what is not working for you. You can copy the table, fields and scripts over... or even recreate them manually (like you have to for the layouts and custom functions)...

  • Author

You need a different kind of VBscript for selecting a file. But the rest of the logic stays the same. For an example VBscript that selects just one file, download the VBScript demo db at www.grokittools.com

  • 4 weeks later...

Just a smidge off-topic, but if you really want to have some fun with FM and VBScript, grab this:

Script Kit

Enjoy! There are about 2200 scripts that do everything from create, populate, and print Word docs to adding/deleting users from an Active Directory. I got these from the MS Script Repository, imported them from Access into FMP (via ODBC), and wrote up a little something to run them.

  • Author

You'll find the same thing on the downloads page of my website: www.connectingdata.com. Called VBscript repository...

  • 6 years later...

Hi Wim,

Thanks for this great example....

its works great ...but one things i dnt undrstnd..nd that is...how u stored the selected folder's path in return path field ..?

  • Author

The VBscript creates a CSV file on the hard disk and the FM script imports that.

yeah ..But how u get the path(value) of the return path....?

and i want to show file also in browse th folder dialog box...but user can select only folder ..this thing is possible with script or without VBscript... ????

suppose this ...code for show files in dialog box

 

Dim objShell
Dim strFileName
Dim strFilePath
Dim objFile
Set objShell = CreateObject("Shell.Application")
Set objFile = objShell.BrowseForFolder(0, "Choose a file:", &H4000)
strFileName = objFile.Title
strFilePath = objFile.self.Path
MsgBox "Just the file name: " & strFileName & vbcrlf & "The full path: " & strFilePath  
Set objFileName = Nothing
Set objFilePath = Nothing
Set objShell = Nothing
 
 
now how to store selected item's path in fm databse...
 
please write down the steps..
 
thank you

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.