July 14, 200916 yr Can FM create a new folder on the OS? For instance, I want to script a name based on the date and project, to be used to make a new folder on the desktop. Then my data backup script would export the table(s) data into that folder. thanks
July 14, 200916 yr Possibly with AppleScript or using a Plug-In - but no native ability in FM. I don't think that's right; at least not on Windows. Try a calculation like this: Let ( [ path = Get ( DesktopPath ); folder = "MyFolder"; pathLength = Length ( path & folder ); winPath = Right ( path & folder; pathLength - 1 ) ]; "cmd /c c: && md " & Quote ( winPath ) ) The above calculation works for me using native Filemaker on Windows. I don't know Macs at all but I would be quite surprised if FM couldn't do it given the fact that FM interacts with the Mac OS much better than it does on Windows. I forgot one thing: You need to execute the calculation using Filemaker's SEND EVENT. Edited July 14, 200916 yr by Guest Forgot something
July 15, 200916 yr Nice one Ted! I'm sure there's something similar on Apple but I'm not that clued up on apple events either. Must admit, given the simple use of the "cmd" like this it's surprising those folks down at FMI haven't created a suite of truly built in functions to address OS level issues.
July 15, 200916 yr This made me think of the trick to store a zipped folder in a container and export it when you need to create a folder. However, I don't think you'll have the capability to rename the folder.
July 15, 200916 yr The disadvantage of the FileMaker-only method of exporting a container is that, unless you test for the existence of the folder first,* you could overwrite an existing folder. Command line tools do not do that; by default they only create the folder if it does not exist. On a Mac you have a similar command to md. It is mkdir. Generally I run such commands from FileMaker via AppleScript, using Perform AppleScript and the do shell script command. Example (you really only need the single do shell script line, if you have a path (quoted with single quotes, to escape spaces, etc.): set theDesktop to POSIX path of (path to desktop) set notes_folder to theDesktop & "MorningNews/" do shell script "mkdir -p " & notes_folder -- p option creates subdirectories as needed, and suppresses an error if the folder already exists * You might be able to do this by trying to Export a test file to the folder, then capturing the error. But I don't know if you can suppress the error. I'd rather use command line myself, which is made to do this.
October 2, 200916 yr On a Mac you have a similar command to md. It is mkdir. Just a minor correction… the Windows command "md" can also use "mkdir"—they are identical. http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/mkdir.mspx And now for my problem… : I'm trying to implement the AppleScript "do shell script" option and am not getting anywhere. I'm actually using FileMaker 6 and populating a temporary global text field with this calculation: "do shell script ""mkdir -p """ & "afp" & "://" & resources::file_server_ip_address & "/" & "LSI Public" & "/" & "Inspection Reports" & "/" & order_number & """""" If I grab that calculated code, it looks like this: do shell script "mkdir -p "afp://10.0.0.103/LSI Public/Inspection Reports/00000"" And if I run that in the AppleScript Editor, I just get "" for a result, which leaves me with no clues to carry on with. I'll keep putzing with it, but if anyone can spot the problem, I'd appreciate it!
October 2, 200916 yr Hah, OK… the -p suppresses errors, like you said, Fenton. So when I take out the -p, I get this: mkdir: afp://10.0.0.103/LSI Public/Inspection Reports/00000: File exists Only it doesn't exist, and it refuses to be created…
October 2, 200916 yr I think I figured it out. I replaced "afp://10.0.0.103" with "/Volumes" and I got my folder created.
Create an account or sign in to comment