У меня есть аудио, видео и JPG файлы. Я использую ffmpeg, чтобы получить всю длительность
все работает идеально, я получил все длительности от a для l oop и установил его в переменную, когда я повторяю его, он работает отлично, но когда Я вывожу его в файл .txt, он печатает только последний цикл, любое предложение ниже - мой код
$file = "D:\edl\input\aa.xlsx"
$sheetName = "Sheet1"
#Create an instance of Excel.Application and Open Excel file
$objExcel = New-Object -ComObject Excel.Application
$workbook = $objExcel.Workbooks.Open($file)
$sheet = $workbook.Worksheets.Item($sheetName)
$objExcel.Visible=$false
#Count max row
$rowMax = ($sheet.UsedRange.Rows).count
#Declare the starting positions
$rowName,$colName = 1,1
$rowAge,$colAge = 1,2
$rowCity,$colCity = 1,3
$rowMessage,$colMessage = 1,9
#loop to get values and store it
for ($i=0; $i -le $rowMax-1; $i++)
{
$id = $sheet.Cells.Item($rowName+$i,$colName).text
$name = $sheet.Cells.Item($rowAge+$i,$colAge).text
$subtitle = $sheet.Cells.Item($rowCity+$i,$colCity).text
$filename2 = "$id.jpg"
$filename = "$id.mp4"
$filename1 = "$id.m4a"
$duration2 = if ((ffmpeg -i $filename2 2>&1 | Out-String) -match 'Duration:\s+([\d:.]+)') { $matches[1] };
$duration1 = if ((ffmpeg -i $filename1 2>&1 | Out-String) -match 'Duration:\s+([\d:.]+)') { $matches[1] };
$duration = if ((ffmpeg -i $filename 2>&1 | Out-String) -match 'Duration:\s+([\d:.]+)') { $matches[1] };
if($duration2){
$duration2 = "02:00:11:15"
$bb = $duration2
$out = "$i" + " " + "AX" + " " + "V" + " " + "C" + " " + "00:00:00:00" + " " + $bb + " "+ "* FROM CLIP NAME: " + $id+".jpg"
}
if($duration1){
$out1 = "$i"+ " " + "AX" + " " + "AA" + " " + "C" + " " + "00:00:00:00" + " " + $duration1 + " " + "* FROM CLIP NAME: " + $id+".m4a"
}
if(!$duration){
}else{
$out2 = "$i" + " " + "AX" + " " + "AA/V" + " " + "C" + " " + "00:00:00:00" + " " + $duration + " "+ "* FROM CLIP NAME: " + $id+".mp4"
}
$gg = $out+"`n"+"`n"+$out1+"`n"+"`n"+$out2+"`n"
echo $gg
$gg | Out-File -FilePath d:\edl\input\output.txt
}
#close excel file
$objExcel.quit()
, когда я отображаю переменную $ gg
, это вывод
0 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 1aef53e6-92ac-4d28-89f8-4cce28fa0f58.jpg
0 AX AA C 00:00:00:00 00:00:03.48 * FROM CLIP NAME: 1aef53e6-92ac-4d28-89f8-4cce28fa0f58.m4a
0 AX AA/V C 00:00:00:00 00:00:07.64 * FROM CLIP NAME: 1aef53e6-92ac-4d28-89f8-4cce28fa0f58.mp4
1 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 9a52a954-ffe9-4420-a701-68988923f81f.jpg
1 AX AA C 00:00:00:00 00:00:03.46 * FROM CLIP NAME: 9a52a954-ffe9-4420-a701-68988923f81f.m4a
0 AX AA/V C 00:00:00:00 00:00:07.64 * FROM CLIP NAME: 1aef53e6-92ac-4d28-89f8-4cce28fa0f58.mp4
2 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 20b92847-72eb-455d-98ce-6661ed52951e.jpg
2 AX AA C 00:00:00:00 00:00:03.52 * FROM CLIP NAME: 20b92847-72eb-455d-98ce-6661ed52951e.m4a
2 AX AA/V C 00:00:00:00 00:00:09.75 * FROM CLIP NAME: 20b92847-72eb-455d-98ce-6661ed52951e.mp4
3 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 73aa1f8e-1067-4efd-b2bd-6748a088f33a.jpg
3 AX AA C 00:00:00:00 00:00:03.21 * FROM CLIP NAME: 73aa1f8e-1067-4efd-b2bd-6748a088f33a.m4a
2 AX AA/V C 00:00:00:00 00:00:09.75 * FROM CLIP NAME: 20b92847-72eb-455d-98ce-6661ed52951e.mp4
4 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.jpg
4 AX AA C 00:00:00:00 00:00:03.05 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.m4a
4 AX AA/V C 00:00:00:00 00:00:06.93 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.mp4
но мой текстовый файл выводится
4 AX V C 00:00:00:00 02:00:11:15 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.jpg
4 AX AA C 00:00:00:00 00:00:03.05 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.m4a
4 AX AA/V C 00:00:00:00 00:00:06.93 * FROM CLIP NAME: 1877c551-ceef-48e9-a1a5-00629a9964eb.mp4