我正在尝试制作一个带有名单列表的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
提前致谢 更新:发布给自己的答案
答案 0 :(得分:1)
在macscripter.net获得StefanK的帮助
以下是完整的代码:
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