Newbies David Wilson Posted February 7, 2008 Newbies Posted February 7, 2008 I need to pull a list of files from a folder for a value list. two problems: If I copy and past the filenames from the folder to the value list, they don't sort properly - how to fix? secondly, it would be wonderful if the value list could just look to the folder to grab the names, so that it would be updated as the folder changes - is that possible?
The Big Bear Posted February 7, 2008 Posted February 7, 2008 David There are a couples of ways of doing the second question whick should fix the first question of sorting. To get the value list form a field, use your value list that you have created and instead of checking use custom values, check use values from field and press the specify field button. This requires a relationship between the tables. Or you could use a value list from another file. You would create the value list in the file and on the field you want to use as the value list. Attached this value list to the field you want to display the value list. Hope this makes sense to you. Lionel
Newbies David Wilson Posted February 10, 2008 Author Newbies Posted February 10, 2008 No, I'm not making a value list from a field, I have a folder of audio files, I'd like to put the Names of the audio files in a value list. I can find no way to have items in a folder to turn up in a value list, so I've copied and pasted the audio file names from the folder to the value list. I just tried again, now it is sorting. I don't have the original file I was working with, so I'll need to try it again back at work. It would be much cleaner if I could grab the filenames from the folder though, so I don't have to remember to update the value list every time I open it up.
comment Posted February 10, 2008 Posted February 10, 2008 Filemaker doesn't have a native ability to get the contents of a folder (unless it's a folder of images or text files). However, you could do this with AppleScript or a plugin. AppleScript can be run from within a Filemaker script, or you could configure your folder to run an AppleScript when its contents are modified. Whichever method you choose, it would be better, IMHO, to base the value list on a table. Updating a table is a user process, and it can be entirely automated. Updating a custom value list is a developer process, and I am not sure how much of it is open to access by AppleScript. Not to mention that value lists based on field contents are automatically sorted.
Fenton Posted February 10, 2008 Posted February 10, 2008 Yeah, I don't think there's any way (outside of using GUI operations using System Events, tricky and clunky) to update a Custom Value List using AppleScript. The simplest method would be using AppleScript to grab the file names, which is easy if you know the folder path, in AppleScript syntax (with colons, etc.). list folder (path to folder) try this, in the Script Editor application (every Mac has this) list folder ( choose folder ) Set that into a FileMaker global field, then parse them out with an incrementing counter. Or alternatively, write the file names to a text file, delete your existing records in that table, then Import the file. Another interesting method, which does not have much to do with value lists, but is more dynamic, is to use a (free) plug-in, like zippShell. The command line tool 'ls' will list files in a folder, and the plug-in will show them in a FileMaker field. This is dynamic and does not require a script. It is somewhat more difficult to do anything with the files though, when they are just lines in an unstored calculation field (which it has to be, and which means you can't use it as is in a value list).
Tyra Posted March 12, 2008 Posted March 12, 2008 Fenton, do you have an example of how to "Set that into a FileMaker global field, then parse them out with an incrementing counter"? I need to parse out a text field that has a list of names in it to a table so that I can use them as the file names for importing. The text field looks like this: Filelist" Record.223443.xml Record.324500.xml Record.340089.xml" I am playing with Troi File plugin to retrieve the file list from a folder, now just need to turn that list into separate feilds.
Fenton Posted March 12, 2008 Posted March 12, 2008 It's just a loop, taking out the values one at a time. You would turn that into separate "records," putting the value into a field, not "fields." (You're worrying me about your relational design.) Pseudo code: Loop Set Field [ global_file_name; GetValue ( gFileNames; 1 ) # get the 1st value, put it into a global field of its own Set Field [ gFileNames; RightValues ( ValueCount ( gFileNames ) - 1) ] # remove the 1st value from the global list of files # do something with that 1st value, create a record and put it in a text field, whatever Exit Loop If [ ValueCount ( gFileNames) = 0 ] End Loop
Fenton Posted March 12, 2008 Posted March 12, 2008 Or, alternatively, use a counter. Set Variable [ $count; ValueCount ( gFileNames ) ] Loop Set Variable [ $counter; $counter + 1 ] Set Field [ global_file_name; GetValue ( gFileNames; $counter ) # do something with that 1st value, create a record and put it in a text field, whatever Exit Loop If [ $counter = $count ] End Loop
Tyra Posted March 13, 2008 Posted March 13, 2008 Thanks Fenton, this is the last piece of the puzzle that I needed to figure out in regards to the issue that you helped with. (Topic#193907) I was searching throughout the forums incase it had already been answered. And this was close to what I was trying to do. By the way, I meant field, not fields.
Recommended Posts
This topic is 6100 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now