Jump to content

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


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

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 4 months later...

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?

Link to comment
Share on other sites

  • 2 weeks later...

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)...

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

  • 6 years later...

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... ????

Link to comment
Share on other sites

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
Link to comment
Share on other sites

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.