I want to make applescript to create a folder in Mobile Document How do I do this i search everywhere but Can't find any
Try google search terms:
applescript make new folder
If the found results don't answer your question, then ask again, providing more details. I don't have a "Mobile Document" folder on my disk, and since you didn't tell us where yours is located, you'll have to be more specific. Tell us exactly where you want the new folder to be created, and what you want its name to be.
OK if a applescript wont work. I want my app to right a file to a folder when the button is pressed. How can I do that?
Where did I say an AppleScript won't work? Where does any of the search results say that it's impossible to have an AppleScript make a new folder?
Post the code you have now. If you don't have any code, tell us what tutorial or reference you're learning AppleScript from. Be specific: URL of tutorial, or title, author, and edition of book.
If you're not learning AppleScript from a guided source like a tutorial or book, what are you learning from? If you don't know the fundamentals, you won't be able to write anything yourself. All you can do is paste together bits and pieces you find.
tell application "Finder"
set p to (path to) Macintosh HD:Users:Desktop-- Or whatever path you want
make new folder at p with properties {name:"New Folder"}
end tell
Is this for interacting with iCloud? If so, Apple has specific documentation on how to do that.
path to desktop
Ok Thanks a lot! But say I want the folder to be created in the ~/Libary folder how would I write that in AppleScript?For example let's say you want to make a new folder on the desktop.
You haven't changed the name of your startup disk and your username is david then the following code :
Code:path to desktop
will give a result of : alias "Macintosh HD:Users:davidesktop:"
If you run this on another mac where you changed the name of the startup disk to MyBigDisk and you log on with the username black then the same code will give a result of : alias "MyBigDisk:Users:blackesktop:"
Info about the path to (folder) command and the special folder for which to return the path on this link : https://developer.apple.com/library/mac/#documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_cmds.html#//apple_ref/doc/uid/TP40000983-CH216-SW19
You'll find it in the Commands Reference section. Or perhaps the path to resource might be of use to you as well.
Try this :
Code:tell application "Finder" set p to path to library folder from user domain make new folder at p with properties {name:"New Folder"} end tell
Ok. Thanks how to place the path into the user mobile documents folder?
tell application "Finder"
set p to path to mobiledocuments folder from user domain
make new folder at p with properties {name:"New Foldergyg11tr"}
end tell
set p to path to mobiledocuments folder from user domain
What is this "Mobile Document" folder? I know I don't have it on my disk. The question has been asked already but you haven't provided an answer. Have you looked at the link I provided? Do you see any reference to the mobiledocuments folder in the special folder for which to return the path. Maybe I skipped over it but I just checked and it is not there so this :
Code:set p to path to mobiledocuments folder from user domain
isn't going to work. It seems like you're pasting together bits and pieces you find, hoping it will work. As you noticed things start to fail pretty quick by doing this. Please provide more information, post a screenshot of the location of this mysterious "Mobile Document" folder or continue what you've been doing without success.
tell application "Finder"
set p to (path to library folder from user domain as text) & "Mobile Documents:"
make new folder at p with properties {name:"TEST"}
end tell
Unfortunately I don't have/use ICloud so I don't know if you're allowed to create folders in that Mobile Documents folder but you can try this :
Code:tell application "Finder" set p to (path to library folder from user domain as text) & "Mobile Documents:" make new folder at p with properties {name:"TEST"} end tell
tell application "Finder"
set p to (path to library folder from user domain as text) & "Mobile Documents:"
try
set newFolder to make new folder at p with properties {name:"TESTING"}
make new alias at (path to home folder) to newFolder
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end tell
Try this :
Code:tell application "Finder" set p to (path to library folder from user domain as text) & "Mobile Documents:" try set newFolder to make new folder at p with properties {name:"TESTING"} make new alias at (path to home folder) to newFolder on error the error_message number the error_number display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try end tell
set exePath to (path to home folder as text) & "SetFileIcon"
set imagePath to (path to desktop folder as text) & "Actions.icns"
tell application "Finder"
set p to (path to library folder from user domain as text) & "Mobile Documents:"
try
set newFolder to make new folder at p with properties {name:"TESTING"}
make new alias at (path to home folder) to newFolder
on error the error_message number the error_number
display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1
end try
end tell
do shell script quoted form of POSIX path of exePath & " -image " & quoted form of POSIX path of imagePath & " -file " & quoted form of POSIX path of (newFolder as text)
Info : http://www.google.be/search?client=safari&rls=en&q=applescript+set+folder+icon&ie=UTF-8&oe=UTF-8&redir_esc=&ei=gSFCUaKuFOec0QXMhICgCQ
http://macscripter.net/viewtopic.php?id=36587
http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html
Code:set exePath to (path to home folder as text) & "SetFileIcon" set imagePath to (path to desktop folder as text) & "Actions.icns" tell application "Finder" set p to (path to library folder from user domain as text) & "Mobile Documents:" try set newFolder to make new folder at p with properties {name:"TESTING"} make new alias at (path to home folder) to newFolder on error the error_message number the error_number display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try end tell do shell script quoted form of POSIX path of exePath & " -image " & quoted form of POSIX path of imagePath & " -file " & quoted form of POSIX path of (newFolder as text)
This is the syntax errorInfo : http://www.google.be/search?client=safari&rls=en&q=applescript+set+folder+icon&ie=UTF-8&oe=UTF-8&redir_esc=&ei=gSFCUaKuFOec0QXMhICgCQ
http://macscripter.net/viewtopic.php?id=36587
http://www.hamsoftengineering.com/codeSharing/SetFileIcon/SetFileIcon.html
Code:set exePath to (path to home folder as text) & "SetFileIcon" set imagePath to (path to desktop folder as text) & "Actions.icns" tell application "Finder" set p to (path to library folder from user domain as text) & "Mobile Documents:" try set newFolder to make new folder at p with properties {name:"TESTING"} make new alias at (path to home folder) to newFolder on error the error_message number the error_number display dialog "Error: " & the error_number & ". " & the error_message buttons {"OK"} default button 1 end try end tell do shell script quoted form of POSIX path of exePath & " -image " & quoted form of POSIX path of imagePath & " -file " & quoted form of POSIX path of (newFolder as text)
set exePath to (path to home folder as text) & "SetFileIcon"
set imagePath to (path to desktop folder as text) & "Actions.icns"
set theFolder to (path to desktop folder as text) & "docs:doc"
Strange. It looks like there is no space between the & and "docs:doc" but it is not really clear. Try with another folder name or type the single set theFolder line in another script editor window and see if it compiles.
Code:set exePath to (path to home folder as text) & "SetFileIcon" set imagePath to (path to desktop folder as text) & "Actions.icns" set theFolder to (path to desktop folder as text) & "docs:doc"
I am still getting a error.
do shell script quoted form of POSIX path of exePath & " -image " & quoted form of POSIX path of imagePath & " -file " & quoted form of POSIX path of (newFolder as text)
do shell script quoted form of POSIX path of exePath & "-image" & quoted form of POSIX path of imagePath & "-file" & quoted form of POSIX path of theFolder
& " -image " &
& "-image" &
You're getting an error because you didn't copy and paste the do shell script line exactly as it was posted.
It should be this:
Code:do shell script quoted form of POSIX path of exePath & " -image " & quoted form of POSIX path of imagePath & " -file " & quoted form of POSIX path of (newFolder as text)
You have this:
In your code, you've left out the spaces that are between the quotes.Code:do shell script quoted form of POSIX path of exePath & "-image" & quoted form of POSIX path of imagePath & "-file" & quoted form of POSIX path of theFolder
For example, in the original:
but in yours:Code:& " -image " &
Look very carefully, because these are not the same. The quoted spaces are required.Code:& "-image" &
And you made the same mistake where you have "-file".