刻录视频的文件以备份DVD

时间:2014-03-22 23:50:13

标签: applescript

我正在使用AppleScript将教堂布道的文件刻录到DVD进行备份。关于我们的流程的一句话。

我们有一台Sony数码摄像机,用于视频服务。我将这些文件下载到iMovie中,创建一个iMovie项目,并将这些文件拼接在一起。我添加了一个开头标题&结束学分,我以两种分辨率分享到媒体浏览器。之后,我将较小的分辨率文件上传到教会的网站。然后,我使用更大的分辨率文件创建一个iDVD项目。

我已经获得了iMovie项目的模板,其开头标题为&已经有结束信用,iDVD项目的模板,以及打印出DVD标签的另一个模板。我已经编写了AppleScript,它会在特定的一周内复制这些模板。这很好。

我已经在第二个脚本上完成了大量工作,以便在我的桌面文件夹中创建刻录文件夹并在其中创建文件夹&创建原始文件的别名/快捷方式。但是,鉴于我们要在此处复制的视频,我需要确保将所需的最少数据量刻录到磁盘上。

具体来说,本周原始视频的iMovie Events文件夹中有两个由iMovie创建的文件夹,我不想刻录到DVD。一个是缓存&另一个有缩略图。如果我在打开iMovie时因任何原因需要恢复备份,则应重新创建这些内容。

所以我只想复制事件文件夹中不是这两个文件夹的文件。这些文件夹名为iMovie Movie CacheiMovie Thumbnails

如何排除这两个文件?我已经得到了代码。

-- Script to copy the iMovie project, the iDVD project, and the DVD Label
-- files for a particular week's sermon into a burn folder and then burn it.
property iMovieEvents : alias ((path to movies folder as text) & "iMovie Events.localized:")
property iMovieProjects : alias ((path to movies folder as text) & "iMovie Projects.localized:")
property iMovieSermonsPath : alias ((iMovieProjects as text) & "Sermons:")
property sermonDocumentsPath : alias ((path to documents folder as text) & "Sermons:")

global burnFolder
global thisSermonsPath
global thisSermonsDvdLabels
global thisSermonsdvdproj
global thisSermonsiMovieEvents
global thisSermonsiMovieProject
global sermonCode

to copySermonFiles()
    -- Start a conversation with the Finder
tell application "Finder"
        -- Create a folder in the burn folder for the iMovie Events
        set theFolder to my createFolder(burnFolder, "iMovie Events.localized")

        -- Give this operation 5 mintues to complete        
        with timeout of (5 * 60) seconds
            -- Copy the Sermon's iMovie Events folder to the Burn Folder.
            -- Need to exclude the iMovie Movie Cache & iMovie Thumbnails folders here
            make new alias at theFolder to folder thisSermonsiMovieEvents
        end timeout

        -- Create a folder in the burn folder for the Sermon's iMovie Project.
        set theFolder to my createFolder(burnFolder, "iMovie Projects.localized")

        with timeout of (5 * 60) seconds
            -- Copy the Sermon's iMovie Project file to the Burn Folder
            make new alias at theFolder to file thisSermonsiMovieProject
        end timeout

        -- Create a folder in the burn folder for the Sermon's documents
        set theFolder to my createFolder(burnFolder, "Documents")

        -- Create a folder in the burn folder's Documents folder for the sermon
        set theFolder to my createFolder(theFolder, sermonCode)

        -- Copy the Sermon's iDVD Project and DVD Labels files to the Burn Folder
        make new alias at theFolder to thisSermonsDvdLabels
        make new alias at theFolder to thisSermonsdvdproj
    end tell
end copySermonFiles

-- Helper method that creates a new folder named theName in the dst folder.
to createFolder(dst, theName)
    -- Create a string that contains the path to the folder we're going to create
    set thePath to (dst as text) & theName

    -- Start a conversation with the Finder
    tell application "Finder"
        -- Does the folder exist already?
        if not (exists thePath) then
            return make new folder at dst with properties {name:theName}
        else
            return alias thePath
        end if
    end tell
end createFolder

to createBurnFolder()
    -- Create the name of the Burn Folder
    set burnFolderName to sermonCode & ".fpbf"
    set desktopPath to (path to desktop) as text

    -- Compute the path to the Sermon's folder in the Documents:Sermons folder.
    set burnFolderPath to desktopPath & burnFolderName

    -- Start a conversation with the Finder
    tell application "Finder"
        -- Does the burn folder exist?
        if not (exists burnFolderPath) then
            -- Create the burn folder
            set burnFolder to make new folder at desktopPath with properties {name:burnFolderName}
        else
            set burnFolder to folder burnFolderPath
        end if
    end tell
end createBurnFolder

to getThisSermonsFiles()
    -- Ask the user to pick the Sermon's iMovie Project file.
    set thisSermonsiMovieProject to choose file with prompt "Please select the Sermon's iMovie Project:" default location iMovieSermonsPath

    -- Extract the sermon code from the Sermon's iMovie Project file name.
    set fileext to ".rcproject"
    set fileName to (name of (info for thisSermonsiMovieProject))
    set sermonCode to text 1 thru ((length of fileName) - (length of fileext)) of fileName

    -- Build the path to the Sermon's iMovie Events folder
    set thisSermonsiMovieEvents to ((iMovieEvents as text) & sermonCode & ":")

    -- Build the path to the Sermon's DVD & DVD Labels files.
    set thisSermonsPath to (sermonDocumentsPath as text) & sermonCode & ":"

    -- Build the path to this Sermon's DVD Labels file.
    set thisSermonsDvdLabels to alias (thisSermonsPath & sermonCode & ".cndx")

    -- Build the path to this sermon's iDVD Project file.
    set thisSermonsdvdproj to alias (thisSermonsPath & sermonCode & ".dvdproj")
end getThisSermonsFiles

on run
    -- Get the sermon code from the user
    getThisSermonsFiles()

    -- Create the Burn folder
    createBurnFolder()

    -- Copy the files into the burn folder.
    copySermonFiles()
end run

1 个答案:

答案 0 :(得分:1)

Finder有一个“谁”的克劳斯,可以轻松过滤Finder项目列表。因此我们可以用它来排除事物。您还可以将文件或文件夹称为“项目”,以包含在一个短语中。因此,如果您希望从文件夹中获取对所有文件和文件夹的引用,并按名称排除某些项目,那么这样的工作就可以了......

set itemNamesToExclude to {"iMovie Movie Cache", "iMovie Thumbnails"}

tell application "Finder"
    set itemsToMove to items of folder thisSermonsiMovieEvents whose name is not in itemNamesToExclude
    -- move itemsToMove somewhere
end tell