Hi Sue

I don't need this to work cross=platform as this is a fully Mac business. I downloaded the Troi application trial to see if it might work and noticed it has a change name function, which seems like it could work. However, I do not yet understand how to accomplish what I want to do with it. Any chance you could share a simple script that would move and rename an image file using Troi? I am envisioning that a user would locate a file to be moved, then click a button which would run a script to rename the image to a calculated name, move the image to a new location, and record the new filepath in a text field. If it were possible, and it looks as if it might be, it would be great to be able to resize and change the image format too.

A typical script would be like this
Set Variable [ $file; Value:TrFile_SetDefaultType( "-Unused" ; "") ]
Set Variable [ $file; Value:TrFile_SelectFileDialog ( "-Unused"; "Select a file" ) ]
//A dialog box appears allowing the user to select a file
If [ Left ( $file  ; 2 ) = "$$" ]
Beep
Show Custom Dialog [ Title: "Error"; Message: "Procedure error or user canceled the procedure"; Buttons: “OK” ]
Exit Script [  ]
End If
Set Variable [ $file2; Value:Globals::fileserverpath & Middle ( $file ; Position ( $file ; ":" ; Length ( $file ) ; -1 ) + 1 ; 999 )] //This formula retrieves everything that comes after the last :, that is the name of the file //Globals::fileserverpath is a global field in which the path to the central folder has been stored Set Variable [ $err; Value:TrFile_CopyFile( "-Unused" ; $file1 ; $file2 ) ]
//The actual copying takes place
//You might want to add some error checking here, both for non availability of the remote volume and for same-name file
Set field (files table::Path; $file2)
//Writes the path to the copied file into a field

if you want to rename the file you can change the step
Set Variable [ $file2; Value:Globals::fileserverpath & Middle ( $file ; Position ( $file ; ":" ; Length ( $file ) ; -1 ) + 1 ; 999 )]
to
Set Variable [ $file2; Value:Globals::fileserverpath & "your file name here"]

As far as changing image format is concerned my knowledge is much more limited since I've never been asked to do that Image resizing is possible but a bit convolute IIRC: you should set a containe field to a thumbnail originated by the copied image, setting the thumbnail size to the one desired, then export it to the final location

HTH, let me know if you need more info

Ciao
G. Pupita
Certified FileMaker 8 Developer
FileMaker Business Alliance

Reply via email to