innodes Posted July 14, 2009 Posted July 14, 2009 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
IdealData Posted July 14, 2009 Posted July 14, 2009 Possibly with AppleScript or using a Plug-In - but no native ability in FM.
innodes Posted July 14, 2009 Author Posted July 14, 2009 kind'of thought that might be the case. thanks again,
Ted S Posted July 14, 2009 Posted July 14, 2009 (edited) 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, 2009 by Guest Forgot something
IdealData Posted July 15, 2009 Posted July 15, 2009 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.
bcooney Posted July 15, 2009 Posted July 15, 2009 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.
Fenton Posted July 15, 2009 Posted July 15, 2009 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.
HazMatt Posted October 2, 2009 Posted October 2, 2009 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!
HazMatt Posted October 2, 2009 Posted October 2, 2009 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…
HazMatt Posted October 2, 2009 Posted October 2, 2009 I think I figured it out. I replaced "afp://10.0.0.103" with "/Volumes" and I got my folder created.
Recommended Posts
This topic is 5530 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 accountSign in
Already have an account? Sign in here.
Sign In Now