Скопируйте несколько файлов в папку в приложении для новичков - PullRequest
1 голос
/ 11 марта 2012

Я пытаюсь создать Applescript, который берет список имен и создает из него набор папок. А затем копирует файлы из выбранной папки в каждую из этих вновь созданных папок.

Я ищу ответ, но не понимаю их. Так что, если бы вы могли так любезно объяснить, что и почему я должен изменить код, это было бы отличным опытом для меня.

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 dest  inationFolder & 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

Спасибо заранее Обновлено: ответ на свой вопрос

1 Ответ

1 голос
/ 11 марта 2012

Получил помощь от StefanK на macscripter.net

Вот полный код:

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
try
    set theFiles to (choose file with prompt "Where are the files at?" with multiple   selections allowed)
end try
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
       try
           tell application "Finder" to duplicate theFiles to folder newFolder
       end try
end if
end repeat
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...