October 17, 201312 yr Hello I am trying to write a script which exports a set of records in fp7 format. the filename is appended by the current date. In the first instance I can't get the filepath to work. I can get it to work by just entering a filename into the export files dialog box ie file:filename, but this dumps the file into the Filemaker Pro folder or I can get it to work by putting the entire filepath. filemac:/Volume/Users/admin/desktop/filemame the problem is this would only work on my computer and this is a shared database - is there a generic filepath I can use which could solve this I have tried various combinations For example file:/desktop/filename But keep getting the same message ie File could not be created on this disc..... Does anyone know what I am doing wrong Many thanks
October 17, 201312 yr Author Ok thanks for that I have got that working using get (desktopPath) the only problem now is the actual filename What I want is a filename appended with the date the file was produced So I have set up a calculation field which holds the filename and the date (using get (currentdate) this works OK and I can see the correct filename in the field I have set up a variable which uses this field so the filepath looks like this $Filepath/$filename If I type text in as the filename it works but it does not seem to want to accept a variable - it either throws it out or sets the actual filename as $filename Anyone know what I could be doing wrong Many thanks for reading
October 17, 201312 yr it does not seem to want to accept a variable - it either throws it out or sets the actual filename as $filename What exactly does "throws it out" mean"? I am also not clear on the "or" part: computers are not capricious - you must have changed something on your part to get a different result. Such as removing the $ prefix from the variable name. Properly, your entry in the Export Records step should look like this: filemac:$filepath/$fileName I don't think the absence of the 'filemac:' prefix should make a difference, but it's worth checking. The other thing is that the result of Get ( CurrentDate ) is very likely (depending on your date format in use) to contain forward slashes - and you will get an error message in such case, because a file name of "10/17/2013" will try to create a file named "2013" in a folder named "17" in a folder named "10" in the directory specified by $filepath.
October 18, 201312 yr When saving a file and appending the current date using Get(CurrentDate) I wrap that function in the Sustitute function and replace the slashes with underscores. Today would be 10_17_2013. This avoids escaping the slashes and it's easy to understand.
October 18, 201312 yr IMHO, it would be better to calculate a result of "20131017" or similar. This way the files would be sorted correctly by name alone.
October 18, 201312 yr I'm missing something about the sorting. Do you mean how they would be sorted in a finder window? Rick.
October 21, 201312 yr Author Solution Hi all That has cracked it Putting filemac: and using the substitute function to change the date seemed to do the trick So final script looks like this Set variable [$filename; Value:Substitute (Table::Filename;"/";"-"0)] Set Variable [$Filepath; Value:Get (DesktopPath)] Export records ["$filename";Automatically open; Unicode UTF-16)] With a filepath of Filemac:$Filepath/$Filename The filename field holds the name of the file and the current date
February 9, 20169 yr in everytime, if I want to choose where I will export , which way should I use in Export records with script ? I want to see " Export records to file" with "Excel workbooks(*.xlsx)" as record type. Than I will give name of "filename" in everytime. Edited February 9, 20169 yr by Mustafa55
February 9, 20169 yr Just use a plain Export Records without anything else - unfortunately, it will always default to Tab Separated, but it's in the drop down to change to Excel. Also might be better to start a new thread for questions that were last answered 18 months ago...
Create an account or sign in to comment