Applescript:删除两个定义的字符之间的一系列字符

时间:2013-10-14 12:49:40

标签: applescript

我有一个类似下面的字符串,我想删除看起来像这样的字符范围:28%57%85%20%40%59%79%99%每隔一行。

'/Users/studiotwo/Desktop/Test/originals/
  analyzing ...
    [1/33] "003.wav": 28%57%85%-12.3 LUFS (-10.7 LU)
        peak: 0.0 TPFS, range: 0.0 LU
    [2/33] "04.wav": 28%57%85%-19.8 LUFS (-3.2 LU)
        peak: -3.5 TPFS, range: 0.0 LU
    [3/33] "pb_1.wav": 28%57%85%-13.9 LUFS (-9.1 LU)
        peak: 0.2 TPFS, range: 0.0 LU
    [4/33] "pb_10.wav": 20%40%59%79%99%-22.1 LUFS (-0.9 LU)
        peak: -3.2 TPFS, range: -23.1 LU
    [5/33] "pb_11.wav": 25%51%76%-22.0 LUFS (-1.0 LU)
        peak: -6.4 TPFS, range: 0.0 LU
    [6/33] "pb_12.wav": 24%47%71%94%-21.9 LUFS (-1.1 LU)
        peak: -3.5 TPFS, range: -22.1 LU

1 个答案:

答案 0 :(得分:0)

您可以使用do shell script来运行像sed 's/": [^-]*/: /"'这样的sed命令:

set input to "'/Users/studiotwo/Desktop/Test/originals/
  analyzing ...
    [1/33] \"003.wav\": 28%57%85%-12.3 LUFS (-10.7 LU)
        peak: 0.0 TPFS, range: 0.0 LU
    [2/33] \"04.wav\": 28%57%85%-19.8 LUFS (-3.2 LU)
        peak: -3.5 TPFS, range: 0.0 LU
    [3/33] \"pb_1.wav\": 28%57%85%-13.9 LUFS (-9.1 LU)
        peak: 0.2 TPFS, range: 0.0 LU
    [4/33] \"pb_10.wav\": 20%40%59%79%99%-22.1 LUFS (-0.9 LU)
        peak: -3.2 TPFS, range: -23.1 LU
    [5/33] \"pb_11.wav\": 25%51%76%-22.0 LUFS (-1.0 LU)
        peak: -6.4 TPFS, range: 0.0 LU
    [6/33] \"pb_12.wav\": 24%47%71%94%-21.9 LUFS (-1.1 LU)
        peak: -3.5 TPFS, range: -22.1 LU"
do shell script "sed 's/\": [^-]*/\": /' <<< " & quoted form of input without altering line endings

请注意,如果do shell script长于input(或当前为2 ^ 18)个字节,则getconf ARG_MAX命令会返回错误。 without altering line endings禁止将行结尾转换为CR。