Applescript 在应用程序上放置文件夹:排序内容:制作MOV
以下是我试图实现的目标: 第1项。将包含多个图像序列的文件夹放到小程序上Applescript 在应用程序上放置文件夹:排序内容:制作MOV,applescript,Applescript,以下是我试图实现的目标: 第1项。将包含多个图像序列的文件夹放到小程序上 firstImageSeq0001.png firstImageSeq0002.png firstImageSeq0003.png secondImageSeq0001.png secondImageSeq0002.png secondImageSeq0003.png thirdImageSeq0001.png thirdImageSeq0002.png thirdImageSeq0001.png 第2项。获取文件夹中的
firstImageSeq0001.png
firstImageSeq0002.png
firstImageSeq0003.png
secondImageSeq0001.png
secondImageSeq0002.png
secondImageSeq0003.png
thirdImageSeq0001.png
thirdImageSeq0002.png
thirdImageSeq0001.png
第2项。获取文件夹中的每组序列并制作成quicktime mov
我目前使用的脚本允许我在小程序的文件夹中放置一个图标,然后用第一组图像创建一部电影。我如何让它继续到下一组图像
on open collection
tell application "Finder" to set theSequence to first item of folder collection as alias
tell application "QuickTime Player 7"
activate
open image sequence theSequence frames per second 30
set nameSequence to (theSequence as string) & ".mov"
tell document 1
with timeout of 500 seconds
save self contained in nameSequence
end timeout
end tell
end tell
end open
我有各种各样的例行程序。这是伪代码。如果我有时间,我会添加更多具体内容(除非你觉得这是一个足够好的切入点): (“basename”在这里是指编号前的文件名文本)
最简单的方法是继续处理第一项,但一旦处理完毕,请删除所有具有相同根名称的文件,然后再次运行。下面的脚本就是这样做的 您必须根据文件名定义LastDigitCount。例如,对于FirstimageSeq0001.png,LastDigitCount应至少为8,这意味着“0001.png”被排除在序列的根名称之外
set lastDigitsCount to 8 -- number of chars from the right which contain extension and counters
set myFolder to "imac27:Users:my_user:Desktop:test:"
repeat
tell application "Finder"
if ((count items of folder (myFolder as alias)) = 0) then return
set theSequence to first item of folder myFolder as alias
set RootName to name of theSequence
set RootName to text 1 thru ((length of RootName) - lastDigitsCount) of RootName
end tell
-- make your quicktime routine here
tell application "QuickTime Player 7"
activate
open image sequence theSequence frames per second 30
set nameSequence to (theSequence as string) & ".mov"
tell document 1
with timeout of 500 seconds
save self contained in nameSequence
end timeout
end tell
end tell
-- delete all files with same rootname
tell application "Finder"
set myPNG to every item of folder (myFolder as alias) whose name contains RootName
delete myPNG
end tell
end repeat
我认为这是可行的,只是它删除了所有文件,包括新的quicktime文件。如何排除新的mov文件?抱歉,请将删除前的行更改为排除扩展名为“mov”的文件:将myPNG设置为文件夹(myFolder作为别名)中((名称扩展名不是“mov”)且名称包含RootName的每一项
set lastDigitsCount to 8 -- number of chars from the right which contain extension and counters
set myFolder to "imac27:Users:my_user:Desktop:test:"
repeat
tell application "Finder"
if ((count items of folder (myFolder as alias)) = 0) then return
set theSequence to first item of folder myFolder as alias
set RootName to name of theSequence
set RootName to text 1 thru ((length of RootName) - lastDigitsCount) of RootName
end tell
-- make your quicktime routine here
tell application "QuickTime Player 7"
activate
open image sequence theSequence frames per second 30
set nameSequence to (theSequence as string) & ".mov"
tell document 1
with timeout of 500 seconds
save self contained in nameSequence
end timeout
end tell
end tell
-- delete all files with same rootname
tell application "Finder"
set myPNG to every item of folder (myFolder as alias) whose name contains RootName
delete myPNG
end tell
end repeat