更新:AppleScript:进度条显示太多文件

发布于 2025-01-12 21:49:52 字数 5399 浏览 6 评论 0原文

好的,我已经弄清楚如何通过 do shell script 中的 find 命令获取文件计数,以及如何将其合并到 AppleScript 进度显示中。但是...

新问题

当我使用以下 find shell 命令时,它会返回目录中适当数量的文件(在本例中为 2)

set mlvCount to do shell script "find /Volumes/EOS_DIGITAL/DCIM/**/*.MLV -iname *.MLV | wc -l"
display dialog mlvCount

但是,当我尝试将其与进度显示结合起来,突然脚本告诉我有 8 个文件正在传输。

这是我正在使用的脚本:

--> Import Video
            
if button returned of result = "VIDEO" then 

display dialog "What video files are you importing?" with icon note buttons {"Magic Lantern Raw", "Other"}
                
if button returned of result = "Magic Lantern Raw" then
                    
display dialog "Remounting EOS DIGITAL as read only" with icon note buttons {"OK"}
                    
    set driveName1 to "EOS_DIGITAL"
                    
    set driveInfo1 to do shell script "diskutil list | grep \"" & driveName1 & "\""
                    
    set driveID1 to last word of driveInfo1
                    
    do shell script "diskutil unmount " & driveID1 & ""
                    
    do shell script "diskutil mount readOnly " & driveID1 & ""
                    
    set mlvCount to do shell script "find /Volumes/EOS_DIGITAL/DCIM/**/*.MLV -iname *.MLV | wc -l"
                    
                    ----> Progress bar
                    
                    -- UPDATE INITIAL PROGRESS INFO
                    
                    set fileCount1 to length of mlvCount
                    set progress total steps to fileCount1
                    set progress completed steps to 0
                    set progress description to "Transfering MLV files..."
                    set progress additional description to "Preparing to transfer."
                    
                    repeat with a from 1 to length of mlvCount
                        
                        -- UPDATE THE PROGRESS DETAIL
                        
                        set progress additional description to "Transfering file " & a & " of " & fileCount1
                        
                        -- TRANSFER FILES
                        
                        do shell script " rsync -av --progress /Volumes/EOS_DIGITAL/DCIM/**/*.MLV" & space & loc & captureDate & "/_CAPTURE/_VIDEO/_MLV/"
                        
                        -- INCREMENT THE PROGRESS
                        
                        set progress completed steps to a
                        
                        -- Pause for demonstration so progress is seen
                        
                        delay 1
                        
                    end repeat
                    
                    
                    -- RESET PROGRESS INFO
                    
                    set progress total steps to 0
                    set progress completed steps to 0
                    set progress description to ""
                    set progress additional description to ""
                    
                    
                    ----> Progress bar end
                    
                    display dialog "Transfer complete. Ejecting " & quoted form of driveName1 & "" with icon note buttons {"OK"}
                    
                    do shell script "diskutil unmount " & driveName1 & ""

对我做错了什么有什么想法吗?

///////////////////

原始帖子

这是我在这里的第二个问题。第一个运气很好,所以就到这里。

概述

我是一名纪录片制片人,目前正在构建一个 AppleScript 应用程序,以加快我的工作流程,创建捕获目录并将原始视频和音频文件自动传输到这些捕获文件夹。

该应用程序本质上是自动化 DIT(数字成像技术人员)。

大多数繁重的工作(即将文件从采集卡传输到采集目录)都是通过 shell 脚本使用 rsync 完成的。

问题:

我想添加一个可视化进度条,显示已传输的文件数和剩余的文件数。我每个拍摄日都会传输 250 - 750GB 的素材,因此需要一个进度条。

我知道 AppleScript 有一个内置的进度条命令,但是我不知道如何将此引用为“do shell script”命令。我还需要进度条来显示传输文件的进度,而不是整个脚本的进度。

脚本:

这是我正在使用的脚本片段,其中涵盖了摄像机镜头的传输:

display dialog "What files are you importing to the directory " & quoted form of captureDate & "?" with icon note buttons {"VIDEO", "AUDIO", "STILLS"}
            
--> Import Video
            
if button returned of result = "VIDEO" then display dialog "What video files are you importing?" with icon note buttons {"Magic Lantern Raw", "Other"}
                
    if button returned of result = "Magic Lantern Raw" then
                    
    display dialog "Remounting EOS DIGITAL as read only" with icon note buttons {"OK"}
                    
    set driveName1 to "EOS_DIGITAL"
                    
    set driveInfo1 to do shell script "diskutil list | grep \"" & driveName1 & "\""
                    
    set driveID1 to last word of driveInfo1
                    
    do shell script "diskutil unmount " & driveID1 & ""
                    
    do shell script "diskutil mount readOnly " & driveID1 & ""
                    
    do shell script " rsync -av --progress /Volumes/EOS_DIGITAL/DCIM/100EOS5D/*.MLV" & quoted form of loc & "/" & quoted form of captureDate & "/_CAPTURE/_VIDEO/_MLV"
                    
                    ----> Progress bar
                    
                    
                    
                    ----> Progress bar end

非常感谢任何帮助!提前致谢!

Ok, so I've figured out how to grab the file count through the find command in do shell script, and how to incorporate it into the AppleScript progress display. HOWEVER...

New Problem

When I use the following find shell command, it returns the appropriate number of files in the directory (in this case, 2)

set mlvCount to do shell script "find /Volumes/EOS_DIGITAL/DCIM/**/*.MLV -iname *.MLV | wc -l"
display dialog mlvCount

However, when I try to incorporate this with the progress display, all of a sudden the script is telling me that there are 8 files being transferred.

Here's the script I'm working with:

--> Import Video
            
if button returned of result = "VIDEO" then 

display dialog "What video files are you importing?" with icon note buttons {"Magic Lantern Raw", "Other"}
                
if button returned of result = "Magic Lantern Raw" then
                    
display dialog "Remounting EOS DIGITAL as read only" with icon note buttons {"OK"}
                    
    set driveName1 to "EOS_DIGITAL"
                    
    set driveInfo1 to do shell script "diskutil list | grep \"" & driveName1 & "\""
                    
    set driveID1 to last word of driveInfo1
                    
    do shell script "diskutil unmount " & driveID1 & ""
                    
    do shell script "diskutil mount readOnly " & driveID1 & ""
                    
    set mlvCount to do shell script "find /Volumes/EOS_DIGITAL/DCIM/**/*.MLV -iname *.MLV | wc -l"
                    
                    ----> Progress bar
                    
                    -- UPDATE INITIAL PROGRESS INFO
                    
                    set fileCount1 to length of mlvCount
                    set progress total steps to fileCount1
                    set progress completed steps to 0
                    set progress description to "Transfering MLV files..."
                    set progress additional description to "Preparing to transfer."
                    
                    repeat with a from 1 to length of mlvCount
                        
                        -- UPDATE THE PROGRESS DETAIL
                        
                        set progress additional description to "Transfering file " & a & " of " & fileCount1
                        
                        -- TRANSFER FILES
                        
                        do shell script " rsync -av --progress /Volumes/EOS_DIGITAL/DCIM/**/*.MLV" & space & loc & captureDate & "/_CAPTURE/_VIDEO/_MLV/"
                        
                        -- INCREMENT THE PROGRESS
                        
                        set progress completed steps to a
                        
                        -- Pause for demonstration so progress is seen
                        
                        delay 1
                        
                    end repeat
                    
                    
                    -- RESET PROGRESS INFO
                    
                    set progress total steps to 0
                    set progress completed steps to 0
                    set progress description to ""
                    set progress additional description to ""
                    
                    
                    ----> Progress bar end
                    
                    display dialog "Transfer complete. Ejecting " & quoted form of driveName1 & "" with icon note buttons {"OK"}
                    
                    do shell script "diskutil unmount " & driveName1 & ""

Any ideas of what I'm doing wrong?

////////////////////

Original Post

this is my second question on here. Had great luck with the first one so here goes.

The overview:

I'm a documentary filmmaker currently building an AppleScript application to speed up my workflow that creates capture directories and transfers raw video and audio files automatically to those capture folders.

The application is essentially automating a D.I.T. (digital imaging technician).

Most of the heavy lifting (i.e. the transferring of files from capture cards to capture directory) is done with rsync through shell scripts.

The problem:

I want to include a visual progress bar showing how many files have been transferred against how many are remaining. I'm transferring between 250 - 750gb of footage for each shoot day so a progress bar will be needed.

I know AppleScript has a built in progress bar command, however I can't figure out how to make this reference the "do shell script" commands. I also need the progress bars to display the progress of the transferred files, not the progress of the script as a whole.

The script:

Here's a snippet of the script I'm working with that covers the transferring of camera footage:

display dialog "What files are you importing to the directory " & quoted form of captureDate & "?" with icon note buttons {"VIDEO", "AUDIO", "STILLS"}
            
--> Import Video
            
if button returned of result = "VIDEO" then display dialog "What video files are you importing?" with icon note buttons {"Magic Lantern Raw", "Other"}
                
    if button returned of result = "Magic Lantern Raw" then
                    
    display dialog "Remounting EOS DIGITAL as read only" with icon note buttons {"OK"}
                    
    set driveName1 to "EOS_DIGITAL"
                    
    set driveInfo1 to do shell script "diskutil list | grep \"" & driveName1 & "\""
                    
    set driveID1 to last word of driveInfo1
                    
    do shell script "diskutil unmount " & driveID1 & ""
                    
    do shell script "diskutil mount readOnly " & driveID1 & ""
                    
    do shell script " rsync -av --progress /Volumes/EOS_DIGITAL/DCIM/100EOS5D/*.MLV" & quoted form of loc & "/" & quoted form of captureDate & "/_CAPTURE/_VIDEO/_MLV"
                    
                    ----> Progress bar
                    
                    
                    
                    ----> Progress bar end

Any help is greatly appreciated! Thanks in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文