Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Can FM create a new folder on the OS?

Featured Replies

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

Possibly with AppleScript or using a Plug-In - but no native ability in FM.

  • Author

kind'of thought that might be the case.

thanks again,

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 by Guest
Forgot something

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.

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.

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.

  • 2 months later...

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!

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…

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

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.