mkdir shell script permissions problem creating folders

The following script works on some folders and some folders I get this error:

“mkdir: folder: Permission denied”

Anyway around this? Any information would be greatly appreciated.

Thanks,
CarbonQuark


tell application "Finder"
	select the front Finder window
	set targetFolder to insertion location as alias
	set folderPath to POSIX path of targetFolder
end tell

set makeBannerFolders to "mkdir -p " & folderPath & "/{JOB' 'FOLDER1/FOLDER/{SUB1/SUB1A,SUB2,SUB3,SUB4},FILES,RAW/{SUB1,SUB2/{SUB2A,SUB2B}},JOB' 'FOLDER2}/"
do shell script makeBannerFolders

Hi,

Have you checked the read/write permissions on the enclosing folder? You can do this by selecting the folder, pressing Cmd-I and look at the Sharing and Permissions section.

Also I had an issue because the folder path had a space in it. To get around this I used ‘quoted form of’ to enclose the folderPath string with quotes. Without this it was writing to the root folder, perhaps your current user does not have write permissions to the root folder.

tell application "Finder"
	select the front Finder window
	set targetFolder to insertion location as alias
	set folderPath to POSIX path of targetFolder
end tell

set makeBannerFolders to "/bin/mkdir -p " & quoted form of folderPath & "/{JOB' 'FOLDER1/FOLDER/{SUB1/SUB1A,SUB2,SUB3,SUB4},FILES,RAW/{SUB1,SUB2/{SUB2A,SUB2B}},JOB' 'FOLDER2}/"
do shell script makeBannerFolders

I’d recommend reading this page if you’ve not already:
http://developer.apple.com/technotes/tn2002/tn2065.html

Best wishes

John M

John M,

It’s people like you that make forums like this great.

It was the spaces in the path. ‘quoted form of’ did the trick!

Thanks!
CarbonQuark

I’m glad it helped.