[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 idwma 于 2021-10-11 23:39 编辑
  1. @powershell "type '%~0'|select -skip 1|out-string|iex"&pause&exit
  2. [IO.File]::ReadAllLines("draft_content.json") -split "{"|%{
  3.   if ($_ -match '"material_name":"(.*?)","material_url":"","path":"(.*?)"'){$name=$matches[1];$path=$matches[2]}
  4.   if ($_ -match '"content":"(.*?)"'){[array]$a+=$matches[1]}
  5.   if ($_ -match '"duration":(.*?),"start":(.*?)}'){
  6.     if ($matches[2] -ne 0){
  7.       [array]$b+=(("{0:HH:mm:ss,ff}" -f [datetime]([int64]$matches[2]*10)),("{0:HH:mm:ss,ff}" -f [datetime](([int64]$matches[2]+[int64]$matches[1])*10))) -join ' --> '
  8.     }
  9.   }
  10. }
  11. for($i=0;$i -le $a.count;$i++){
  12.   $c+=($i+1),$b[$i],$a[$i],"",""
  13. }
  14. $c>([io.path]::GetDirectoryName($path)+"\"+[io.path]::GetFileNameWithoutExtension($path)+".srt")
复制代码

TOP

回复 3# tianzi


    路径目录和json文件里的不一样?

TOP

回复 5# tianzi


    多发几个不行的样本来测试一下

TOP

回复 8# tianzi


    时间是直接用json文件里的值,有差异就不知道了

TOP

回复 10# tianzi

用时间简单点
  1. @powershell "type '%~0'|select -skip 1|out-string|iex"&pause&exit
  2. [IO.File]::ReadAllLines("draft_content.json") -split "{"|%{
  3.   if ($_ -match '"material_name":"(.*?)","material_url":"","path":"(.*?)"'){$name=$matches[1];$path=$matches[2]}
  4.   if ($_ -match '"content":"(.*?)"'){[array]$a+=$matches[1]}
  5.   if ($_ -match '"duration":(.*?),"start":(.*?)}'){
  6.     if ($matches[2] -ne 0){
  7.       [array]$b+=(("{0:HH:mm:ss,ff}" -f [datetime]([int64]$matches[2]*10)),("{0:HH:mm:ss,ff}" -f [datetime](([int64]$matches[2]+[int64]$matches[1])*10))) -join ' --> '
  8.     }
  9.   }
  10. }
  11. for($i=0;$i -le $a.count;$i++){
  12.   $c+=($i+1),$b[$i],$a[$i],"",""
  13. }
  14. $d=[io.path]::GetDirectoryName($path)+"\"+[io.path]::GetFileNameWithoutExtension($path)+".srt"
  15. if(test-path $d){$c>([io.path]::GetDirectoryName($path)+"\"+[io.path]::GetFileNameWithoutExtension($path)+("{0:HH.mm.ss}" -f (get-date))+".srt")}else{$c>$d}
复制代码

TOP

返回列表