2012-03-11 99 views
1

我正在尝试制作一个Applescript,它需要一个名称列表并从中创建一组文件夹。然后将选定文件夹中的文件复制到每个新创建的文件夹中。将多个文件复制到新手appelscript中的文件夹

我有搜寻的答案,但不明白他们。所以,如果你可以善意地解释什么,为什么我应该改变代码,这对我来说将是一次很好的学习经历。

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 

在此先感谢 更新时间:发布答案自己

+0

这是该计划的所有沿。当我找到答案时,我不得不等待5个小时才能发布答案。另有48个可以接受它。所以耐心的男孩。 – Runar 2012-03-11 21:33:52

+0

所以我最终从这个问题中学到了一些东西...... – adayzdone 2012-03-12 01:51:14

回答

1
从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 
相关问题