set destinationFolder to choose folder
set {text returned:textReturned} to display dialog "enter folder names" default answer return & return & return
if textReturned is "" then return
repeat with aLine in (get paragraphs of textReturned)
if contents of aLine is not "" then
tell application "Finder" to make new folder at destinationFolder with properties {name:aLine}
end if
end repeat
Use the shell script equivalent, it skips existing folders automatically with the -p switch
set destinationFolder to choose folder
set {text returned:textReturned} to display dialog "enter folder names" default answer return & return & return
if textReturned is "" then return
repeat with aLine in (get paragraphs of textReturned)
if contents of aLine is not "" then
do shell script "/bin/mkdir -p " & quoted form of (POSIX path of destinationFolder & aLine)
end if
end repeat
Trying to expand the script. Adding the posebility to fill the folders with files, but not getting it right
I have have tried every file in a folder, cause I couldn’t manage to make a list of files choosen by the user. That was my first thought though. Asking the user to input multiple files and adding them all. Could only get it to work with one file.
set destinationFolder to choose folder
set {text returned:textReturned} to display dialog "enter folder names" default answer return & return & return
if textReturned is "" then return
set folderWithFiles to (choose folder with prompt "Where are the files at?")
repeat with aLine in (get paragraphs of textReturned)
if contents of aLine is not "" then
do shell script "/bin/mkdir -p " & quoted form of (POSIX path of destinationFolder & aLine)
set folderNew to aLine & ":" as alias
set dest to folderNew on destinationFolder -- as alias
tell application "Finder"
duplicate every file of folderWithFiles to dest
end tell
end if
end repeat
If you want to ask the files for each new folder, try this
set destinationFolder to choose folder
set {text returned:textReturned} to display dialog "enter folder names" default answer return & return & return
if textReturned is "" then return
repeat with aLine in (get paragraphs of textReturned)
if contents of aLine is not "" then
set newFolder to (destinationFolder as text) & aLine
do shell script "/bin/mkdir -p " & quoted form of POSIX path of newFolder
set theFiles to (choose file with prompt "Where are the files at?" with multiple selections allowed)
tell application "Finder" to duplicate theFiles to folder newFolder
end if
end repeat
Wow. That was fast
Thanks a lot. Works like a charm. Wanted the same files in all folder so I moved the “choose files” out of the loop.
Coding is weird. Small changes make all the difference