Jump to content

Moving Scripts to another computer


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

Recommended Posts

Hello,

I have a database which i have created for several users . the problem is is that as i use an applescript or two to "alias" files (an applescript and another database ) when i copy the database to another computer the "alias" is lost and the scripts fail .

any ideas

Paul Apted

Link to comment
Share on other sites

There are a couple options. You can use the "path to me" to construct a relative path to your files. Alternatively you can place each of the offending statements in the follow sort of construction...

try

-- put the statement likely to fail here

on error

--prompt the user to find the file here

end try

Link to comment
Share on other sites

The following will give you the parent folder of the location of your script...

set oldDlm to AppleScript's text item delimiters

set AppleScript's text item delimiters to ":"

set myPath to (path to me) as string

set ParentCt to count of text items of myPath

set parentPath to text items 1 thru (ParentCt - 2) of myPath

set ParentFolder to (parentPath as string) & ":"

set AppleScript's text item delimiters to oldDlm

If run this script from within a Filemaker script, it will return the path to the FileMaker application folder. If this is the case, I would construct the relative path using the Status(CurrentFilePath) function.

Link to comment
Share on other sites

This calculation (unstored) will give you the Mac path to the folder of its FileMaker file:

Substitute(Substitute(Substitute(myPath, "file://", ""), "/", ":"), Status(CurrentFileName), "")

You can reference any other folders and files that you know the relative location from the current file.

Link to comment
Share on other sites

Hi Fenton.

That is Excellent.

I found out that your calculation needs to be Result of Text, or you will get "," where there are spaces.

Any way to pull this File Path information into another file. In other words. Lets say I want to have one file tell me the file path of a second file (even if I have to open it).

Lee

Link to comment
Share on other sites

When you say "2nd file," you mean a FileMaker file, right? It's an unstored calculation, using Status functions, each file evaluates for itself.

You can't say Status(CurrentFilePath, "FileX.fp5"). But if you have a Constant relationship to FileX.fp5 you could get its file path from its filepath calculation field. It's going to be the same in every record.

But, when you think about it, you're not going to have a relationship to a file that you don't know where it is; otherwise how'd you set those up in the first place? If you moved the file, these would be broken. And, if you know where it is, you don't need to "get" its filepath; you can calculate it from where you are.

You can't easily use AppleScript to get the filepath of a file by name. It could be anywhere, and there could be more than one of them.

If you had some idea where it might be, in relation to anything else, AppleScript could loop through every file and folder until it found it. This could be slow though.

Link to comment
Share on other sites

  • 3 weeks later...

i have created this little script that will reveal a file if it exists .If it doesn't it asks you where it is and then holds the filepath.

this works fine in the finder as an applet but doesn't work from within Filemaker 5.5

any ideas?

Paul Apted

tell application "Finder"

try

reveal X

on error

choose file

set myfile to result

set X to result as alias

reveal X

end try

end tell

Link to comment
Share on other sites

I'm not quite sure what happens with aliases when you move them to another computer. There are a couple other little things with your script that may be the problem.

It's always a little difficult to keep track of whether to reference a file name as a "file" or an "alias" or as plain text. I think that somewhere this is what is wrong.

1. "reveal X" is not a good reference, unless X is either a file or alias. You don't show us where X is set, so we can't say. If X is text in a FileMaker field, then it should be "file X" or "alias X," unless it's already prefixed with "alias." I prefer not to store the word "alias," as it's less confusing later.

2. The result of "choose file" is an alias. I don't know why you're setting "myFile" to the result, 'cause you don't seem to use it later. Then you set X to result as alias, but it's already an alias.

3. Unless you activate the Finder, you can't always see the revealed file.

Here's how I'd write it:

tell current record of document 1 to set myFile to cell "FilePath"

tell application "Finder"

Link to comment
Share on other sites

OK,

Here is the big Picture . I have a Sound FX database in which every record is linked to a soundfile residing on a hard drive (30,00). by the nature of the database you have to keep the filepath very specific otherwise nothing works .this is fine if there is only one person using this thing but there are about 10 people using it all with different sound Fx , i have built another database called SFX engine which uses the (finder) file name as the relationship to the main database .i have bulit (begged and borrowed to be more exact ) an applescript that works as a drag and drop app which people can drop the SFX they own onto .this extracts the filepath and from that the filename which then links to the main database and hey presto.. a sound plays.

BUT,i have 2 problems when giving the databases to someone else:

1) I have created a wizard ( a pretty layout) that will reveal the Applescript in the finder . This is where the alias problem comes in .All i need to do in filemaker is reveal the applescript.

2) the main script (down below) fails to find the "SFX ENGINE" Database as the alilas (again) is invalid and therefore the script fails .

The script i "built" kind of solves the problem as if it doesn't find the file it asks you where it is and hold's on to for ever more ,but as i am rubbish at applescript i can't get it to work in the main script (again at the bottom)

ANy help would be appreciated

Thanks for your interest

Paul Apted

-- the list of file types which will be processed

property type_list B) {"AIFf", "sd2f", "mp3", "Wav"}

-- This droplet processes both files or folders of files dropped onto the applet

on open these_items

display dialog "Dropped Soundfiles will be entered into the SFX ENGINE"

repeat with i from 1 to the count of these_items

set this_item to (item i of these_items)

set the item_info to info for this_item

if folder of the item_info is true then

process_folder(this_item)

else if (alias of the item_info is false) and (the file type of the item_info is in the type_list) then

process_item(this_item)

end if

end repeat

end open

-- this sub-routine processes folders

on process_folder(this_folder)

set these_items to list folder this_folder without invisibles

repeat with i from 1 to the count of these_items

set this_item to alias ((this_folder as text) & (item i of these_items))

set the item_info to info for this_item

if folder of the item_info is true then

process_folder(this_item)

else if (alias of the item_info is false) and (the file type of the item_info is in the type_list) then

process_item(this_item)

end if

end repeat

end process_folder

-- this sub-routine processes files

-- by creating new FM records and saves the filepath

-----problem area-----

on process_item(this_item)

tell application "FileMaker Pro"

set X to alias "OSX BOX:Users:daddy:Documents:Databases:SFX DATABASE FILES: Latest Version:SFX DATABASE 2.2.1:Databases:SFX Engine"

open X

create new record in the database "SFX Engine"

go to last record

--change this line to agree with your field name

set cell "filepathtext" of current record to (this_item as text)

end tell

end process_item

Link to comment
Share on other sites

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