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

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

Recommended Posts

Posted

I have the need to change a exported filename to a filename from a global text field in the current database. For example rotyapplications.rrd is the file name. I want it to be renamed from a field called outpost# which is a global field and it contains 6. I want the file name to be rotyapp6.rrd. If the outpost# is 153 I want the file to be renamd rotyapp153.rrd and so on.

This is a program to collect Ranger of they Year applications for a District ROTY evaluation event. Each outpost (church boyscouts) would have their own number.

The program is at http://readyrangers.tzo.com/rotyeval.exe and is about 13 meg in size. From the main screen there is a Send Via Email button that exports the data to a field and then sends it on to the ROTY Coordinator where he then imports the file. It works great but I want the file names to match the outpost so the roty coordinator doesn't have to manually rename the file each time he gets one sent to him/her.

Any suggestions.

I can GetasText(Outpost#) in a calculation field but getting that to rename the file is where I need the ideas.

Thanks for your help.

Mark Jones

Posted

Troi File Plug-in has the ability to rename files that are stored as references in FMP. More info at their website.

Posted

once you've exported the file and you know exactly where that file is, you can use a simple Send Event script step to tell the OS to rename the file (and this command can be calculated based on your field):)

cmd /c ren c:old_file.txt c:new_file.txt

Posted

I should probably explain the syntax a little:

cmd /c -> calls the Windows Command Line Interpreter (CLI - aka the black dos box) and tells it to quit when it's done

ren -> the DOS rename command, giving it the path & name of the old file and the path & name of the new file.

There's a lot that you can do with the command line that people always seem to suggest you need a plugin for. Find the ntcmds.chm file on your hard disk for a nice overview of all the commands you can fire...

Posted

I'm curious, Wim.

If you prefer to use Send Event to the OS to handle situations like those addressed in this thread, what do you do about solutions that will be used in a cross platform environment? Write an Applescript also and then check for platform to see which event should be used? Doesn't a plug-in like Troi's File handle this more simply?

What would be the advantage of using Send Event over using a plug-in? (other than the plug-in cost, of course)

Posted

Can't dismiss cost :)

I agree, in an Xplat environment using the OS can be more complex than a plugin. You need both a command line and an applescript and branch the code based on the client OS.

99% of my business is on Windows though so I don't usually have to worry about this.

One nice thing about plugins is that the return their result back into a FM field. The Send Event doesn't. If you want the result of a Send Event back in a FM field there are a lot of hoops to jump through.

I wish FMI would give us a "perform VBscript" script step sooner rather than later :)

Posted

I have used this before using batchfiles to rename files...the hitch is trying to pass the file name to the batch file from a field in Filemaker.

Outpost# is a text field I need to use this variable field to rename the file.

File is created and called rotyapplications.rrd

I want to rename this file rotyapp?.rrd where the ? represents the contents of the outpost# field. Could be a number between 1 and 999.

The answer is in the calcuation part of this but not sure how to get it done.

It may be time to upgrade to 8 as I understand it can do this.

Thanks for your ideas. If you get a work around holler.

Mark Jones

Posted

The command you send with "Send Event" can be fully calculated. So you'd use a cacl field with this calc:

"cmd /c ren c:SomePathrotyapplications.rrd rotyapp" & outpost# & ".rrd"

side note:

You almost never need a batch file even if you have multiple commands to execute. One command line can consist of multiple commands by using the "&", "&&" or "|" operators between commands. There is a limit of about 8000 charactes per command line.

Posted

Well I got Er done by using some simple text files and appending them together using the export command.

I export the outpost# by using export field contents to outpost.txt

Then I have 3 files.

rotyapp.txt contains --- rotyapp

rotyapp2.txt contains ---ren rotyapplications.rrd

rotyapp3.txt contains --- .rrd

Then a simple batchfile called renbat.bat that does this.

del ren1.doc

del ren1.bat

del c:rotysectionapplicationsrotyapp.rrd

type rotyapp2.txt >>ren1.doc

type rotyapp.txt >>ren1.doc

type outpost.txt >>ren1.doc

type rotyapp3.txt >>ren1.doc

copy ren1.doc ren1.bat

call ren1.bat

del rotyapplications.rrd

copy rotyapp*.rrd c:rotysectionapplications

del rotyapp???.rrd

It works great with one exception. Sometimes I have to exit the solution and restart it to get the send event function to run.

Mark Jones

Posted

Way too complex! It seems you're totally focused on making this work with a batch file. But you really don't need one. Really. Half of your batch file is making sure that all the files are deleted.

If you do just one calculated Send Event from your file (to execute the ren command after the export) then you're set. No batch files need to be created and deleted, no intermediate files.

I've attached a demo file:

- script one exports one field to a file named "c:rotyapplications.rrd"

- then run a second script that fires a send event to rename the file using the outpost#

No batch files, everything nice and clean from inside FM.

SendEvent_rename.zip

Posted

Hey Thanks! That worked a lot smoother than my batch files and it works every time!

I didn't realize I could pass a send event like that. I have them running batch files but you have shown me a whole new method and the ability to use the & feature. Much appreciated!

Thanks for putting it in a file. It makes it so much easier to see a working version and get it to work in my solution.

You guys sharing in this forum makes Filemaker the best!

Mark Jones

This topic is 6931 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.