0

我有一个简单格式化的文本文件(编辑决策列表),其中包含数字行,后跟属性行(名称等)。对于每场比赛,我试图从名称字符串中创建一个列表,然后是持续时间(时间戳之间的差异)。

导致:

12 - 科技性感 - D Cebert - FFP170 Dur:00.38

到目前为止我已经

  1. 为用户在他们的桌面上定义源文件建立了一种方式。
  2. 定义了一种对源时间戳进行排序的方法(按相应名称行之前的时间戳)。
  3. 发现前 2 个时间戳之间存在差异。

但我的循环似乎不起作用。我至少希望看到每个匹配的时间戳行的持续时间列表。

到目前为止的脚本:

Option Explicit
'change system location to Germany, to simulate 24hour clock *no AM PM time
SetLocale "de-de"

Dim fso, oFile, y, re, prev, line, matches, time
Set fso = CreateObject("Scripting.FileSystemObject")

'get user to open file name
y = InputBox("name of file to save")

'next line opens a file with that name 
Set oFile = fso.OpenTextFile(y&".edl")

Do Until oFile.AtEndOfStream
    line = oFile.ReadLine
    'At this point the variable prev either is empty (during the first loop
    'cycle) or holds the content of the previous line.
    If Left(line, 21) = "*  FROM CLIP NAME:   " Then
        'Define search terms for each timecode element *this is not a result yet
        Dim re1
        re1 =".*?"  'Non-greedy match on filler
        Dim re2
        re2 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"  'HourMinuteSec 1
        Dim re3
        re3 =".*?"  'Non-greedy match on filler
        Dim re4
        re4 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 2
        Dim re5
        re5 =".*?"  'Non-greedy match on filler
        Dim re6
        re6 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 3
        Dim re7
        re7 =".*?"  'Non-greedy match on filler
        Dim re8
        re8 ="((?:(?:[0-1][0-9])|(?:[2][0-3])|(?:[0-9])):(?:[0-5][0-9])(?::[0-5][0-9])?(?:\s?(?:am|AM|pm|PM))?)"    'HourMinuteSec 4

        'add timecode search terms to a search pattern
        Dim r
        Set r = New RegExp
        r.Pattern = re1+re2+re3+re4+re5+re6+re7+re8
        r.IgnoreCase = True

        Dim m, timeDur, ts, Timeofday
        Set m = r.Execute(line)
        'loop through timecodes to find duration between first 2 entries
        If m.Item(0).SubMatches.Count > 0 Then
            Dim time1
            time1 = m.Item(0).SubMatches.Item(0)
            Dim time2
            time2 = m.Item(0).SubMatches.Item(1)
            Dim time3
            time3 = m.Item(0).SubMatches.Item(2)
            Dim time4
            time4 = m.Item(0).SubMatches.Item(3)

            'find duration/difference between first 2 times, in seconds
            timeDur=datediff("s", time1, time2)
            'format result to a serial time format eg. 00:00:00
            ts = TimeSerial(0, 0, timeDur)
            'print duration result, will need to append track info and repeat. Then save to file
            MsgBox (ts)
        End If
        MsgBox (ts)
    End If
Loop

源文件:

* 评论:草谷为 EDIUS (CMX-3600) 创建
001 0000 交流电 00:00:04:23 00:00:42:04 00:00:00:00 00:00:37:06
* 来自剪辑名称:12 - Tech Sexy - D Cebert - FFP170
002 0000 交流电 00:00:20:01 00:00:31:23 00:01:29:24 00:01:41:21
* 来自剪辑名称:03 - Web Of Deceit(主) - J Woodall - SFT164
003 0000 交流电 00:00:31:23 00:00:31:23 00:01:41:21 00:01:41:21
M2 0000 025.0 00:00:31:23
003 0000 AD 025 00:00:31:09 00:00:54:12 00:01:41:21 00:02:04:24
* 效果名称:交叉溶解
* 来自剪辑名称:03 - Web Of Deceit(主) - J Woodall - SFT164
* 剪辑名称:03 - Web Of Deceit (Main) - J Woodall - SFT164
M2 0000 025.0 00:00:31:09
004 0000 A2 C 00:01:15:08 00:01:31:24 00:01:48:04 00:02:04:20
* 来自剪辑名称:12 - Environs A - T Juckes, S Kidd - SCDV354
005 0000 A2 C 00:00:11:12 00:00:30:05 00:02:06:24 00:02:25:17
* 来自剪辑名称:13 - 传染病(主要) - J Woodall - SFT164
006 0000 A2 C 00:00:06:13 00:00:56:09 00:02:27:04 00:03:17:00
* 来自剪辑名称:03 - Web Of Deceit(主) - J Woodall - SFT164
007 0000 A2 C 00:00:56:09 00:00:56:09 00:03:17:00 00:03:17:00
M2 0000 025.0 00:00:56:09
007 0000 A2 D 025 00:00:55:08 00:01:54:03 00:03:17:00 00:04:15:20
* 效果名称:交叉溶解
* 来自剪辑名称:03 - Web Of Deceit(主) - J Woodall - SFT164
* 剪辑名称:03 - Web Of Deceit (Main) - J Woodall - SFT164
M2 0000 025.0 00:00:55:08
008 0000 A2 C 00:01:15:08 00:01:37:12 00:05:04:10 00:05:26:14
* 来自剪辑名称:12 - Environs A - T Juckes, S Kidd - SCDV354
009 0000 A2 C 00:00:00:00 00:00:26:19 00:06:00:08 00:06:27:02
* 来自剪辑名称:38 - 污染迹象 - W Plass - SCDV354
010 0000 A2 C 00:00:25:08 00:01:13:03 00:06:39:16 00:07:27:11
* 来自剪辑名称:38 - 污染迹象 - W Plass - SCDV354
011 0000 A2 C 00:01:13:03 00:01:13:03 00:07:27:11 00:07:27:11
M2 0000 025.0 00:01:13:03
011 0000 A2 D 025 00:01:48:22 00:02:04:09 00:07:27:11 00:07:42:23
* 效果名称:交叉溶解
* 来自剪辑名称:38 - 污染迹象 - W Plass - SCDV354
* 剪辑名称:38 - 污染迹象 - W Plass - SCDV354
M2 0000 025.0 00:01:48:22
4

0 回答 0