Get clipboard path then run script

The next attempt included adding the ‘/’ in the Bridge script and printing the clipboard data using AppleScript.
This time the ‘/’ printed in the results window when running the AppleScript print clipboard data.
"/Users/Shared/WEB/
"
Nevertheless, when running the folder creation script, the Results window displays:

error “Finder got an error: AppleEvent handler failed.” number -10000

and the following line is highlighted in the AppleScript:

set name of (make new folder at (pathFromClipboard as POSIX file)) to i

Any last-minute thoughts or ideas to solve this ‘/’ mystery in AppleScript?

Try giving this version a shot.

property pathFromClipboard : missing value
property folderNames : {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}

copy (the clipboard) to pathFromClipboard

set pathFromClipboard to (pathFromClipboard & "/") as text

tell application "Finder"
	repeat with i in folderNames
		set name of (make new folder at (pathFromClipboard as POSIX file)) to i
	end repeat
end tell

Thank you for getting back. Still getting:
error “Finder got an error: AppleEvent handler failed.” number -10000

In your working example, how are you getting the folder path into the clipboard?

In Finder, if you control + click on a folder then option + click on “Copy … as Pathname”, the Posix path will be copied.

This solution will get the path of the current selected folder in the front Finder window and create your new folders there.

property folderNames : {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}

tell application "Finder"
	set targetFolderPath to selection
	repeat with thisFolderName in folderNames
		set name of (make new folder at targetFolderPath) to thisFolderName
	end repeat
end tell

Thank you for clarifying how to copy the folder path to the clipboard.
Yes, the solution does create the folder set at the selected finder location.

When there is no finder window open the following message displays:
error “No result was returned from some part of this expression.” number -2763

Can AppleScript use a clipboard path to make a finder window active in the foreground with the path highlighted and then create the folders?

OK let’s ditch all of my previous solutions. Let’s stop worrying about the trailing “/“. This following code should work either way. It won’t make a difference if the folder path, which is on your clipboard, contains the trailing “/“ or not.

property pathFromClipboard : missing value
property folderNames : {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}

copy (the clipboard) to pathFromClipboard
set pathFromClipboard to (pathFromClipboard as POSIX file as alias)

tell application "Finder"
	repeat with thisFolderName in folderNames
		set name of (make new folder at pathFromClipboard) to thisFolderName
	end repeat
end tell

If for some reason this code still doesn’t work for you and if all else fails… this following solution is my “Hail Mary Pass” because after this I’m out of ideas LOL.

I do not have Adobe Bridge on this computer (so I can’t test this) but I believe in Bridge you can choose an option to have any selected folder, to be revealed in Finder and this will open a Finder window with that folder selected. Then this following code should work.

property folderNames : {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}

tell application "Finder"
	set targetFolderPath to selection
	repeat with thisFolderName in folderNames
		set name of (make new folder at targetFolderPath) to thisFolderName
	end repeat
end tell

Thank you so so much for all your help! Your support helped me understand how to use the clipboard to make folders. The last 4 solutions all work well and create the folder set a path stored in the clipboard.

The issue that I was trying to investigate was how to create a set of folders using the Bridge app instead of the OSX Finder. The approach, to use a Bridge script to run the AppleScript at a specific Bridge file location.

Unfortunately, The Bridge app copy file path script produces a clipboard path that is not compatible and produces an AppleScript error. That was well explored in this post with your help. Perhaps, javascript might be a better tool for this task. But that is for another time.

Many thanks for your excellent and valuable help!

Try this revision. Let Bridge set the folder path onto your clipboard. Don’t worry about the trailing “/“.

property pathFromClipboard : missing value
property folderNames : {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}

set pathFromClipboard to (paragraphs of (the clipboard)) as text

tell application "Finder"
	repeat with i in folderNames
		set name of (make new folder at (pathFromClipboard as POSIX file)) to i
	end repeat
end tell

The OP has moved on and I thought it would be OK for me to post an ASObjC suggestion that works in my testing (assuming a usable POSIX path in the clipboard). I thought the NSString property stringByStandardizingPath might be helpful but I don’t understand enough about its operation to include it in my script. The thought also occurred to me that using NSPasteboard might be more robust, but once again my knowledge of that class is very limited. The returned error messages are not as helpful as one might hope but they do often provide some helpful information.

use framework "Foundation"
use scripting additions

set folderNames to {"1.Monday", "2.Tuesday", "3.Wednesday", "4.Thursday", "5.Friday", "6.Saturday", "7.Sunday"}
set thePath to the clipboard as text
display dialog "The clipboard contains the following path" default answer thePath buttons {"Cancel", "Proceed"} cancel button 1 default button 2
set thePath to text returned of result
set thePath to current application's NSString's stringWithString:thePath

set fileManager to current application's NSFileManager's defaultManager()
repeat with aFolder in folderNames
	set aPath to (thePath's stringByAppendingPathComponent:aFolder)
	set {theResult, theError} to (fileManager's createDirectoryAtPath:aPath withIntermediateDirectories:false attributes:(missing value) |error|:(reference))
	if theResult as boolean = false then
		display alert "An error was encountered. The error message was " message (theError's localizedDescription() as text)
		error number -128
	end if
end repeat

Thanks again for this additional suggestion. I try it with the Bridge copy file path script and also manually copying the path through the OSX finder.

In both cases I got the same error “NSString doesn’t understand the “stringWithString_” message.” number -1708 from NSString

The confirmation prompt is a good idea and helps to make sure the clipboard path looks ok.
The irony is that in both cases the path looks good (the Bridge path and the OSX copy path).
But under the hood, they are different.

Sorry to hear that didn’t work, although I can’t say I’m surprised. The clipboard seems a simple utility but it can be quite complex in its operation. In fact, the AppleScript Language Guide discourage this use of the clipboard:

https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-DontLinkElementID_825

Well, when I omit use framework “Foundation”, I get same error