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

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

Recommended Posts

Posted

Hi I would like to open a folder on my mac from each companies records. (Via a button) The folder name would be the company id field and its name. If the folder does not exist I would like it created in the default location. I can get this to work on Access but have no idea how to do this on FileMaker. Can anyone help?

Posted

You may need to use AppleScript to do this.

See the Script command "Perform AppleScript".

Posted

Hi. I am in desperate need of help. I am trying to have a button on a form that will open a folder on my mac (ok that bit was relatively easy) but if the folder does not exist to create one. All the folders would be in the same folder (the actual path is file///Users/JOE/Public/MV Work Folder/) and the folders name would be the fields Company ID and Business Name from the Customers form/table where the button would be. I am told I need to use apple script to do this and have downloaded and installed zippshell as I read on a previous post this would help, but from this point I have no idea what I am doing. I am not even sure how to use a plug in. Please help.

John

Posted

I am told I need to use apple script to do this

Why don't you follow this up in the SAME thread:

http://www.fmforums.com/forum/showtopic.php?tid/192239/

Posted

Jed,

I know you are more interested in the plug in method, but to answer your original question, this is one method for creating a folder using AppleScript:


set theFolderPath to "Macintosh HD:"

set theFolderName to "TestFolder"



tell application "Finder"

	if not (folder (theFolderPath & theFolderName) exists) then

		set returnedPath to make new folder at folder theFolderPath with properties {name:theFolderName}

	end if

end tell

  • Newbies
Posted

Hi there - I had a very similar project, and with a *lot* of AppleScript syntax issues, I finally found a way to open folders safely, with variables from Filemaker... as you can see, there was a lot of string converting to get AppleScript and Filemaker both happy...

Here's the code - but each time I run it, I also double-check to see if the server is mounted, via another AppleScript - you'll get a weird error if the server suddenly becomes unreachable when you try this 'open folder' script...


"set theOutputFolder to "" & Menu Jobs All::Folder Path & "" as string¶

set theOutputFolderName to "" & Menu Jobs All::Folder Name & "" as string¶



tell application "Finder"¶

   set theNewFolder to theOutputFolder & theOutputFolderName as string¶

   if (folder theNewFolder exists) = false then¶

      try¶

         make new folder at theOutputFolder with properties {name: theOutputFolderName }¶

         on error errTxt number errNum¶
            display dialog errTxt & return & errNum¶
      end try¶

   end if¶

   open folder theNewFolder¶

   tell application "Finder" to activate¶

end tell"

let me know if you want/need more info - it was many hours of trial and error, so I'd hate to see it go wasted...

AB out

Posted

Hi Thank you for all of your help. I have tried the script you gave me and I have configured it to my Database but am obviously doing something wrong. I am very new to both File Maker and Apple Scripts. After I have changed it the code now looks like this

"set theOutputFolder to "file:///Users/JOE/Public/MV Work Folders" & Companies::Company ID & Companies::Registered Name & "" as string¶

set theOutputFolderName to "file:///Users/JOE/Public/MV Work Folders" & Companies::Company ID & Companies::Registered Name & "" as string¶



tell application "Finder"¶

   set theNewFolder to theOutputFolder & theOutputFolderName as string¶

   if (folder theNewFolder exists) = false then¶

      try¶

         make new folder at theOutputFolder with properties {name: theOutputFolderName }¶

         on error errTxt number errNum¶
            display dialog errTxt & return & errNum¶
      end try¶

   end if¶

   open folder theNewFolder¶

   tell application "Finder" to activate¶

end tell"

I out this in the Script Maker "Perform AppleScript" and then in "Calculated AppleScript"

I would be really grateful if you could point me in the correct direction.

John

  • Newbies
Posted

Yep - it's just the AppleScript syntax - and the AppleScript error messages - helpful, aren't they...? grrrr....

For a *mounted* Mac hard drive/server, the way to address it is more like this:

ServerName:Folder1:Folder2:

Either hard-code the bove syntax into your script, or use another field to allow you to do more calculations without getting your script syntax horribly wrong...

While I think of it, I installed a tiny folder action to Tiger to let me right-click any folder to get (and copy) it's full folder path - but that script didn't survive the transition to Leopard...

All in all, the quick dive into AppleScript is painful - the error codes are the least helpful I've ever seen - but test it out slowly - get something dead simple working, then change only one variable at a time until you're up to your full requirements.

Let me know if you need more concrete help.

AB out

Posted

As said, AppleScript uses "old style" Mac syntax for paths, with colons. It also requires the hard drive or volume name. So, if it's your computer, and you have not modified the hard drive name, your path would start like:

Macintosh HD:Users:JOE:Public:MV Work Folders:

There's several ways for AppleScript to figure out what your hard drive name is, if you want the AppleScript to work on different user's computers. FileMaker can get this also, with Get ( SystemDrive ). This returns (for me):

/Macintosh HD/

(Once again, you have to Substitute to get colons instead of slashes.)

Since your user name is also in the path you want, you might want to instead use Get ( DocumentsPath ) or Get ( DesktopPath), which includes the short user name. Remove the extra "Documents/" or "/Desktop".

_cUser, calculation, text result, unstored =

Let ( [

DT = Get ( DesktopPath );

p1 = Right ( DT; Length (DT) -1 )

];

Substitute ( p1; ["Desktop/"; ""]; ["/"; ":"] )

)

A simpler pure AppleScript method is just to ask for the path to "special folders" (many). In this case:

path to public folder as Unicode text

Posted

OK I have almost got this working. I am on a very steep learning curve with AppleScript. I have a code that will create a file if it does not exist. And I have specified an open URL script (in filemaker not applescript) to follow it that opens the folder, so far so good. The sticking point I am getting it getting the Field Names I want from the form to become the name of the folder.

I have a line in the AppleScript code:

set theFolderName to

I have tried all the possible variations I can think of but nothing seems to work, I just get those really helpful error messages. I did toy with the idea of setting up a copy script (Again in filemaker) first and this does take the field name I want and puts its into the clipboard but I can not work out how to finish the above code to make it paste this value in. I am so close.

  • Newbies
Posted

Yep - I think I recall the same trouble...

Take a look at my solution, above - on the 'make the folder' line, I had to use a variable that I had to set prior - and to make *that* variable, I had to make sure the strong type (the encoding) was juuust right...

I think I'm about 12 hours behind you, so if you're still stuck at the end of your day, give me an email at [email protected], and I'll shoot you a snippet of my clients' solution when I wake up.

AB

Posted

As AB says, AppleScript has different syntax for folders and files.

make new folder at theOutputFolder with properties {name: theOutputFolderName }

Notice that the "name:" of the folder is a "property" of the folder. (There are other properties, such as "index:", which gives it a label and color.) You can use a variable you've pre-set as the name, as above, or you can use quoted text. You need to use the syntax above however to create a new folder.

After that, yes, you could rename a folder, if you have its full path (in AppleScript syntax).

Posted

Why aren't you supplying an example file so you can be helped with this?

Posted

What example file do you need. I can attached the whole database or if it is just the code I have already included it. Let me know and I will post it.

Posted

Hi Guys, I have done it and it was not as complicated as I thought it would be. Here is the code I ended up using:

set theFolderPath to "Macintosh HD:Users:JOE:Public:MV Work Folders:"

set theFolderName to (cell "CompanyID" of current record & cell "Business Name" of current record)



tell application "Finder"

	if not (folder (theFolderPath & theFolderName) exists) then

		set returnedPath to make new folder at folder theFolderPath with properties {name:theFolderName}

	end if

end tell

This line in the code: (cell "CompanyID" of current record & cell "Business Name" of current record) was the one that was causing me all the problems, but it does reference the field names in the table. Thank for all of your help.

John

  • 2 weeks later...
Posted

I am using the script above to create a folder on my Mac and mentioned in the entries before. This works fine on my local machine. The issue is that the database is also accessed on another network machine (also a mac) and I want that user to be able to do the same thing but the folder path is obviously local. I need a folder path that will access the same folder on my local machine but will work locally or when used on a network. On a PC I know that you can refer to your local machine on the network or map a drive. I do not know how to do this on a mac. If it is of any relevance my mac's network name is Apple1 and ip 172.26.1.65

Posted

This is what the temp and desktop drive is supposed to handle, scrutinize these commands...

http://www.filemaker.com/help/FunctionsRef-221.html

http://www.filemaker.com/help/FunctionsRef-222.html

http://www.filemaker.com/help/FunctionsRef-225.html

http://www.filemaker.com/help/FunctionsRef-227.html

... and while we're at it, why applescript this at all?

http://www.databasepros.com/FMPro?-DB=resources.fp5&-lay=cgi&-format=list.html&-FIND=+&resource_id=DBPros000823

--sd

Posted (edited)

I found this AppleScript someone else wrote. There are 2 sections, with a comment to tell you what each is for:

-- This one will check if a disk is mounted, and if not it will be mounted for you, then the specified folder will be revealed in the Finder.

tell application "Finder"

--this can also be set to the IP address if need be

set ThisVolume to "afp://login:password@Rendesvous_Name.local/Path/To/File"

try

if (list disks) does not contain "NameOfDisk" then mount volume ThisVolume

end try

try

reveal folder "NameOfDisk"

end try

end tell

-- To copy a file simply do something like the following:

tell application "Finder"

set theItem to "path:to:your:item"

set targetFolder to "path:to:target:folder:"

move theItem to targetFolder

end tell

-- Or, using do shell script (the -p option creates intermediate directories for you):

set thePath to "/Volumes/Volume_Name/Public/Food/Donuts/"

do shell script "mkdir -p " & thePath

Edited by Guest
Ignore spaces added by PHP
Posted

Thank you everyone. I have managed it. A combination of mounting a drive and using a Get function and an If function, seems to have worked. I think I am starting to get the hang of FileMaker now. So much better than Access once you know what you are doing, very logical captain

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