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

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

Recommended Posts

Posted

Can ScriptMaster move files between directories? For instance, two directories exist, one called "In" and the other called "Out". In a workflow process, one person manually adds files to the "In" folder. A scheduled script from FileMaker Server would take those files and move them to the "Out" folder (folders would be on the same machine as FM Server).

Moreover, the "In" folder would be completely empty, but the "Out" folder would be cumulative, so files would be added to the directory's existing contents.

I see there is a "DeleteFileOrFolder" and a "CreateFolder", so I imagine the "In" folder could simply get deleted and recreated. That would empty out the folder. However, how would the "Out" folder get populated with said files?

Or, is this an instance of a custom request for 360Works?

Thanks.

Posted

Hi

maybe this command is helpful:

http://www.roseindia.net/java/example/java/io/MovingFile.shtml Or in the Java documentation.

copyFile(File source, File dest)




More information can be found on: 



 
Thanks for your reply, andries. Unfortunately, the solution still eludes me. I don't know Java or Groovy. What do I need to do with the code

?

That seems like the name of the function I'd like, but not the Groovy code.

The link provided does show Java code (see http://www.roseindia.net/java/example/java/io/MovingFile.shtml). Can I use that and then use "copyFile (File source, File dest) as the function name? If so, what are the steps? Do I need to compress the java code . Does that involve creating a .jar file? Does it matter that the .jar file is compressed Java and not Groovy?

Thanks.

copyFile(File source, File dest)
Posted (edited)

you can program in java with scriptmaster.

Simply stated you need two File objects, one for your source and one for your destination.

I hope this can help you on your way (function sends "source" and "dest" as parameters, those parameters are OS filepaths and not FileMaker filepaths). The function name you can choose for your self, so in FileMaker you would see MyFunctionName ( source , dest ).


import java.io.*;



src = new File ( source );

des = new File ( dest );



copyFile(File src, File des);

This is however really short... you should actually first check if the source file exists and if the destination folder exists. This is explained in the link mentioned above. But here on top is in my honest opinion the core of the solution.

Edited by Guest
Posted

andries, thank you for providing a fuller explanation. I apologize that I am not yet able to make this work. Here is what I did:

1. Created a new record item in ScriptMaster

2. Named the record (gave it a function name)

3. Pasted the code above (I understand I should first check that the directories exists, but since I know both do exist, I wanted the shorter version of the code for testing purposes)

4. Added the parameter names

5. Added the parameters (i.e. the file path to the directories)

ScriptMaster returned two error messages (see attached here and in the next two posts).

I have not created a .jar file. Is that something I need to do? Is there something else I am doing incorrectly? Again, I do not know Java at all.

Thanks.

Error_scrn1.png

Posted

indeed I have the same error...

I don't know the method copyFile very well (I am a java noob just as you), so I can't give you the response immediately.

Will take a look at this this weekend.

Posted

Thanks, andries.

I had to smile when you called me a "Java noob". That is very generous. In fact, I don't know Java and it is not on my current list of things to learn - reserving that for PHP, HTML5, CSS3, SQL, French, Spanish, German, Guitar, Tin Whistle, etc. - all while trying to be a husband and dad.

So, I rely on the good nature of people like you!

Looking forward to your weekend results.

Again, many thanks.

Posted

Hi Daniel

no more news at the moment. I spend some time on the subject this weekend, but not with a real result...

I'll will give it another try one of the next evenings.

KR

Andries

Posted (edited)

Hi guys - Andries is on the right track with the File class. However, instead of copyFile (I don't know where that comes from, maybe it's built into Groovy), use the built in renameTo() method built into java.io.File.

The documentation on the file class where you can look this up is here:

http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html

There are a lot of useful things you can do, I would recommend skimming through this. However, for what you're trying to do, here's the quick version:


File moveToFile = new File( moveToPath );

new File( originalPath ).renameTo( moveToFile );

Edited by Guest
Meant to say java.io.File, not FileMaker
Posted (edited)

Hi Jesse

that is indeed the problem I found this weekend: in the Java documentation I don't find any reference to this copyFile method, however it is used in many examples across the internet.

I will try your idea!

Thanks for the help (and for this beautiful plugin!)

Andries

edit: I found out where the copyFile method is coming from... and it will make me look stupid... it is a method implemented by the developers... and not a native method of java... stupid stupid me !

Edited by Guest
Posted

Thanks for your reply, Jesse.

Andries, can you elaborate more on how you got this to work? I'm afraid I'm not as quick to catch on as you are.

I created a new ScriptMaster module and registered it on startup in a database, but now - as the attached db file demonstrates - I'm not sure how to make it work.

What I'd like to do is click the button and have the script move the file on my computer, from one directory to another. Obviously, the database would have to be updated as once the file moves it some of the data (e.g. File Path Orig and File Path Dest) would no longer be correct; so, clicking the button more than once on a record wouldn't work. However, I'm just using this as an example so that I can understand the concept.

Thanks.

SM_moveFile.fp7.zip

Posted (edited)

Daniel, you're almost there - you just need to add on the file name to the path. So where you have this:

original path: /Users/Daniel/Desktop/Test/In/Barn to be Wild.jpg

dest path: /Users/Daniel/Desktop/Test/Out

Change dest path to:

/Users/Daniel/Desktop/Test/Out/Barn to be Wild.jpg

Also make sure that the /Users/Daniel/Desktop/Test/Out/ folder exists, the move command will not create it for you. If you need to create the folder, you can use the 'CreateFolder' ScriptMaster module.

Edited by Guest
Mentioned the 'CreateFolder' module
  • 1 month later...
Posted

Thankyou for this thread. I currently have the move file command working fine between locations on the same drive.

However as soon as I try to save it on the external HD directly or through an alias I get the error 0.

I have tried using file: or filemac:/ or nothing in front at all ie /Volumes/Element2/filename.doc

Any thoughts?

Thankyou

Posted

From the operating system's standpoint, moving files on the same volume is simply a matter of updating a directory pointer somewhere. However, moving them between volumes requires actually reading all of the bits from one storage device and writing them to another.

In ScriptMaster terms, this means that the move file command won't work between volumes. You can accomplish the same thing by using the Copy File module, and then DeleteFileOrFolder after the copy finishes.

  • 4 weeks later...
Posted

Hello

I'm a french new 360works user

I try to move file witch is located on mac mini server (with Fms11) from a client wan

It's not working.

i used in the path the wan an adress like http://xx.xx.xxx.xxx and the name of the field.

I ve made mistake somewhere ??

Thks for your help and sorry for my english :)

Posted

Hi

it will not work work when you use "http" as the path, you should use the native OS paths, like Y: on PC or /Volumes/ on Mac to define the path.

There are already some posts on this forum about the use of filepaths.

Posted

Hi

it will not work work when you use "http" as the path, you should use the native OS paths, like Y: on PC or /Volumes/ on Mac to define the path.

There are already some posts on this forum about the use of filepaths.

Ok thanks for the anwer

all is on MacOs, i try without the http but it doesn't work at all

Bertrand

Posted

hi for example to access the desktop the path on my computer is:

/Users/andries/Desktop/test.jpg

Yes i know that :

But i try to move file from Filemaker client on a wan

FMS is on MacMini server and i'm connect with fm client

i try with :

ip/volumes/server HD/users/toto/desktop/....

But each time i win à 0 wih my $$_moveFile :

Many Thanks for your help Andries

Posted

Can you explain what the goal is? Because I don't understand what you try to achieve.

Ok i try to explain clearly

I have scanned doc on a file in the macMiniServer

i have à Filemaker application running with FMS on the same computer

I want move and rename the scanned file(one by one)in different folder using my FM application even when i'm connected from outside the office at my FMS

I use SM, it works perfectly when i use Filemaker is not working with the FMserver

but when i m connected from outside it does not working anymore

hope you can understand my poor english

thanks for your help

Bertrand

Posted

ok when you want to use scriptmaster (or java) to move files, you need to have physical access to the files.

So when you connect remotely you need to mount the harddisk of the FMServer as an external network drive (someone correct me if I am wrong here...)

Otherwise ScriptMaster is not able to find the file you want to rename/move.

Posted

ok when you want to use scriptmaster (or java) to move files, you need to have physical access to the files.

Unfortunately for me i mout the volume on my desktop before trying .... his name is HD

MoveFiles("/Volumes/HD/doc.pdf" ; "/Volumes/Clients/Try.pdf";"try.pdf" )

Posted

so you have two external harddrives: HD and Clients?

no i've made a mistake

first it's not an external hard drive but the HD of my server

2 i forget to replace the name

you must read :

MoveFiles("/Volumes/HD/doc.pdf" ; "/Volumes/HD/Try.pdf";"try.pdf" )

it works perfectly when i use a local filemaker but when i open server database .... no change anymore

Posted (edited)

Many thanks Andries for your help

i just find the solution

the exact path is

/Volumes/HD/Users/pb_pierron/Desktop/doc.pdf

posix one

for the wan stuff i always don't know how to do

Edited by Guest

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