AnsweredAssumed Answered

Create subfolder

Question asked by tays01s on Jul 17, 2016
Latest reply on Jul 20, 2016 by itraining

I create a folder using this 'Perform Applescript':

"set theOutputFolderPath to path to " & If( $desktopFlag = 1; "desktop"; "documents") & " folder" & ¶ &

"set theNewFolderName to " & Quote( $ns) & ¶ &

"tell application \"Finder\" " &¶ &

"if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then make new folder at theOutputFolderPath with properties {name:theNewFolderName} " & ¶ &

"end tell"

It works fine. However, when I have already created a subfolder (ns_ex) and run the following script again, it fails because it finds there's already a subfolder:

"set theOutputFolderPath to (path to " & If( $desktopFlag = 1; "desktop"; "documents") & " folder as text) &" & Quote($ns) & ¶ &

"set theNewFolderName to " & Quote($ns_ex) & ¶ &

"tell application \"Finder\" " &¶ &

"if (exists folder (theOutputFolderPath & theNewFolderName as string)) = false then make new folder at theOutputFolderPath with properties {name:theNewFolderName} " & ¶ &

"end tell"

 

Note the above subfolder script was adapted from a 'Soliant' script where the subfolder is a date/time, something that constantly changes and therefore simply creates a new subfolder without ever having a problem with the previously created subfolder name.

 

Whilst I don't fully understand Applescript, I can't see why the subfolder command causes an 'Error message' whereas the folder command does not.

Outcomes