Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

I have a script to export a found set of records as a .csv file, but I would like the file to be named dynamically. As it is now, the file is named untitled.csv

Is it possible to have the filename also include the date of the export. ie export-oct-01-04 ?

Thanks

Posted

Not with FileMaker. With AppleScript or a plug-in (or possibly other). What operating system does this have to work on? It's best to specify that when asking questions about external files. I don't want to assume just from your profile, which is Mac, as you may want it to work cross-platform.

The "universal" answer is to export to a fixed-name file and user-accessible common location, then rename with another tool. Just where that location would be, and what tool is the question.

Posted

Thanks for the reply,

It would be used on Mac first, and then possibly used for on Windows as well. I kinda figured that it would be hard to do in filemaker. I know that Excel can do it, so I thought Filemaker might as well.

No big deal, I can work around it.

Thanks again.

Darron

Posted

Actually it's rather easy to do on both platforms, without a plugin.

Both Command line interfaces support the 'echo' command. All you need to do is to loop through each record and calculate an echo command that takes the data of each field you want and sepearate it by a comma. This completely bypasses the FM export engine so it is a flexible as you want it to be.

At the start of the script you would calc an echo command that would result in something like this:

(using the Windows example)

cmd /c echo "fieldname1,fieldname2,fieldname2">c:myCSVexport.csv

Notes:

- "cmd /c" invokes the windows command line interpreter and tells it to quit when done

- echo ... wells echoes what follows literally

- ">c:..." redirects the output to a file instead of to the screen

Then loop through each record and for each one calc an statement like this:

cmd /c echo "data1,data2,data3">>c:myCSVexport.csv

Notes:

- the redirect command is ">>" this time. That one appends to the existing file instead of creating a new file.

The syntax is pretty much the same on OSX since it's Unix.

Posted

Wow,

Thanks for the reply. I definitely would never have thought of that.

Unfortunately, that still doesn't seem to append the name of the export with the current date automatically. Also, I don't think I would be able to write once, then use on both platforms.

Very interesting tho.

This topic is 7354 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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