我有一个大约500个选定文件名的文本文件(每个都在自己的行上)来自我拍摄的超过3,000张照片的事件。我希望能够在文件夹中找到所有这些图像,复制它们,并将这些复制的文件移动到另一个文件夹中。
这是我到目前为止所拥有的。现在它只复制整个3000个图像的文件夹并将其放入目标文件夹,但不是单个文件..
TEXT FILE:
_EPW0847.jpg _EPW0848.jpg _EPW0853.jpg etc....
的AppleScript:
set thePhotos to paragraphs of (read (choose file with prompt "Choose a text file")) set theSourceFolder to (choose folder with prompt "Choose source folder") as string set theDestination to (choose folder with prompt "Choose destination folder") repeat with theName in thePhotos try tell application "Finder" to duplicate alias (theSourceFolder & theName) to theDestination with replacing end try end repeat tell application "Finder" tell folder theDestination to set theCount1 to (count of items) as string end tell set theCount2 to (count of thePhotos) as string display dialog (theCount1 & " of " & theCount2 & " items copied to " & theDestination) buttons {"OK"}
任何帮助都会很棒。我还不清楚苹果脚本,但我正在学习。谢谢!
答案 0 :(得分:0)
你很亲密!
set thePhotos to paragraphs of (read (choose file with prompt "Choose a text file"))
set theSourceFolder to (choose folder with prompt "Choose source folder")
set theDestination to (choose folder with prompt "Choose destination folder")
set dupeList to {}
repeat with theName in thePhotos
try
set end of dupeList to alias ((theSourceFolder as text) & theName)
end try
end repeat
tell application "Finder" to duplicate dupeList to theDestination with replacing
set theCount1 to (count of dupeList) as text
set theCount2 to (count of thePhotos) as text
display dialog (theCount1 & " of " & theCount2 & " items copied to " & (theDestination as text)) buttons {"OK"}
如果文本文件中有空行,请尝试以下操作:
set thePhotos to paragraphs of (read (choose file with prompt "Choose a text file"))
set theSourceFolder to (choose folder with prompt "Choose source folder")
set theDestination to (choose folder with prompt "Choose destination folder")
set dupeList to {}
repeat with theName in thePhotos
try
if theName ≠ "" then
set end of dupeList to alias ((theSourceFolder as text) & theName)
end if
end try
end repeat
答案 1 :(得分:0)
set fileContents to read (choose file with prompt "Choose a comma-delimited text file") set theText to result set AppleScript's text item delimiters to "," set theTextItems to text items of theText set AppleScript's text item delimiters to {""} theTextItems set theSourceFolder to (choose folder with prompt "Choose source folder") as string set theDestination to (choose folder with prompt "Choose destination folder") repeat with theEPSName in theTextItems tell application "Finder" set theEPSFile to theSourceFolder & theEPSName move file theEPSFile to folder theDestination with replacing end tell end repeat