这是一个用于合并歌词的小工具,可以将多个歌词文件合并成一个歌词文件。注意,你首先需要安装 PowerShell,或者在 Windows 应用商店搜索安装。
.\Merge-Lrc.ps1 -Path "C:\Users\user\Music\*.lrc" -MergeMethod "Merge" -SplitChar " " | Out-File "C:\Users\user\Music\merged.lrc"
Merge-Lrc.ps1 [-Path] <String[]> [-MergeMethod <String>] [-SplitChar <String>] [-MaxInterval <Object>] [-Offset <Object>] [<CommonParameters>]
Merge-Lrc.ps1 -LiteralPath <String[]> [-MergeMethod <String>] [-SplitChar <String>] [-MaxInterval <Object>] [-Offset <Object>] [<CommonParameters>]
参数名 | 是否可选 | 默认值 | 说明 |
---|---|---|---|
Path | 否 | 无 | 歌词文件路径,支持通配符。与 LiteralPath 选项互斥。 |
LiteralPath | 否 | 无 | 歌词文件路径,不支持通配符。在文件名中含有特殊字符如 [] 等出错时使用。与 Path 选项互斥。 |
MergeMethod | 是 | Merge | 合并方法。Merge 为合并所有时间相同的行,Intersect 为合并所有时间相同的行并将时间不同的行均分,Union 为合并所有时间相同的行并将时间不同的行合并。 |
SplitChar | 是 | 空格 | 分隔符。 |
MaxInterval | 是 | 10 | Intersect 方法的最大间隔。如果两句歌词超过这个间隔将使用 Offset 中定义的长度来确定下一句歌词的时间。 |
Offset | 是 | 1000 | Intersect 方法的 Offset。最后一句歌词默认使用这个值。如果两句歌词超过这个间隔将使用 Offset 中定义的长度来确定下一句歌词的时间。 |
- 将文件夹中的所有歌词文件合并成一个歌词文件
.\Merge-Lrc.ps1 -Path "C:\Users\user\Music\*.lrc" -MergeMethod "Merge" -SplitChar " "
- 将文件夹中的所有歌词文件合并成一个歌词文件并保存
.\Merge-Lrc.ps1 -Path "C:\Users\user\Music\*.lrc" -MergeMethod "Merge" -SplitChar " " | Out-File "C:\Users\user\Music\merged.lrc"
- 将一个混乱的歌词文件整理合并并保存
.\Merge-Lrc.ps1 -Path "C:\Users\user\Music\test.lrc" -MergeMethod "Intersect" -SplitChar " " | Out-File "C:\Users\user\Music\test.lrc"
- 将一个文件夹下所有的混乱的歌词文件整理合并并保存
dir *.lrc | % { $file = $_; $out = .\Merge-Lrc.ps1 -LiteralPath $file.FullName -MergeMethod "Intersect";$out > $file.FullName }
- 输入文件
[00:10.00][00:00.00][00:01.00]This is the original text.
[00:05.00]This is the next text.
[00:05.00]这是第二句。
[00:10.00][00:00.00][00:01.00]这是中文翻译。
- Merge
[00:00.00]This is the original text. 这是中文翻译。
[00:01.00]This is the original text. 这是中文翻译。
[00:05.00]This is the next text. 这是第二句。
[00:10.00]This is the original text. 这是中文翻译。
- Intersect
[00:00.00]This is the original text.
[00:00.50]这是中文翻译。
[00:01.00]This is the original text.
[00:03.00]这是中文翻译。
[00:05.00]This is the next text.
[00:07.50]这是第二句。
[00:10.00]This is the original text.
[00:11.00]这是中文翻译。
- Union
[00:00.00]This is the original text.
[00:00.00]这是中文翻译。
[00:01.00]This is the original text.
[00:01.00]这是中文翻译。
[00:05.00]This is the next text.
[00:05.00]这是第二句。
[00:10.00]This is the original text.
[00:10.00]这是中文翻译。