Mag*_*dud 5 batch timestamp video-conversion
我需要一种简单的方法将视频转换为 h264,同时保留原始创建日期。
现在我正在手动执行此操作(编码,然后编辑日期),但当我有 10 多个视频时,这是一项超级无聊的任务。
有没有办法自动完成?
带有“保留原始文件日期”选项的转换程序、批处理、脚本:我对任何操作系统上的任何解决方案持开放态度。
测试 将您的视频目录复制到新目录,然后按照以下说明进行操作。
PowerShell脚本
PowerShell 随 Windows 7 一起提供,无需下载。(开始->所有程序->附件->Windows PowerShell)。
以管理员身份启动 PowerShell。
在运行任何脚本之前,您必须第一次执行以下操作(您只需执行一次)
Set-ExecutionPolicy RemoteSigned
Run Code Online (Sandbox Code Playgroud)
回答“是”。
将以下 2 个脚本放入您的视频目录中。打开 PowerShell 并 cd 到您的视频目录。 .ps1是 PowerShell 脚本扩展名。
SaveTime.ps1(视频转换前)
将以下脚本保存为您的视频目录中的SaveTime.ps1。在视频转换之前在PowerShell中运行此脚本。
该脚本将在同一目录中创建OldTime-record.ps1 。
该脚本不会覆盖OldTime-record.ps1。如果文件已经存在,它只会附加到末尾。
因此,如果您意外运行它并丢失原始时间戳,请不要担心。只需使用记事本删除多余的行即可。我在最后添加了一个这种情况的例子。
# SaveTime.ps1 - Start
$file = get-item *
write-output "`$file = New-Object string`[`] $($file.count)" >> OldTime-record.ps1
write-output "`$time = New-Object string`[`] $($file.count)" >> OldTime-record.ps1
$time = New-Object string[] $file.count
for ($i = 0; $i -lt $file.count; $i++) {
write-output "`$file`[$i`]=`'$($file[$i].fullname)`'" >> OldTime-record.ps1
write-output "`$time`[$i`]=`'$($file[$i].CreationTimeUTC.tostring('o'))`'" >> OldTime-record.ps1
}
# SaveTime.ps1 - End
Run Code Online (Sandbox Code Playgroud)
OldTime.ps1(视频转换后)
将以下脚本保存为您的视频目录中的OldTime.ps1。视频转换后在PowerShell中运行此脚本。该脚本将读取OldTime-record.ps1并相应地更改文件创建时间。
# OldTime.ps1 - Start
. .\OldTime-record.ps1
for($i = 0; $i -lt $file.count; $i++) {
write-output "$($file[$i])"
write-output "$($time[$i])"
Set-ItemProperty -Path $($file[$i]) -Name CreationTimeUTC -Value $($time[$i])
}
# OldTime.ps1 - End
Run Code Online (Sandbox Code Playgroud)
旧时记录.ps1
该文件保存文件名和创建时间记录。下面显示了用记事本打开它的样子。
$file = New-Object string[] 9
$time = New-Object string[] 9
$file[0]='E:\Downloads\test\New Folder'
$time[0]='2012-11-13T03:11:11.4504830Z'
$file[1]='E:\Downloads\test\file1'
$time[1]='2012-11-10T01:12:14.6126918Z'
$file[2]='E:\Downloads\test\file2'
$time[2]='2012-11-10T01:12:14.6646918Z'
$file[3]='E:\Downloads\test\file3'
$time[3]='2012-11-10T01:12:14.7276918Z'
$file[4]='E:\Downloads\test\cover.jpg'
$time[4]='2012-11-10T01:12:14.7886918Z'
$file[5]='E:\Downloads\test\OldTime.ps1'
$time[5]='2012-11-13T05:22:18.2124830Z'
$file[6]='E:\Downloads\test\SaveTime.ps1'
$time[6]='2012-11-13T05:44:22.8514830Z'
$file[7]='E:\Downloads\test\test.ps1'
$time[7]='2012-11-13T03:26:28.7084830Z'
$file[8]='E:\Downloads\test\test.time.ps1'
$time[8]='2012-11-13T05:32:51.8204830Z'
Run Code Online (Sandbox Code Playgroud)
以下是如果您意外运行SaveTime.ps1时会发生的情况。它只是将新记录附加在末尾。要修复此问题,只需删除从第二次出现$file = New-Object string[]开始的所有行。
$file = New-Object string[] 9
$time = New-Object string[] 9
$file[0]='E:\Downloads\test\New Folder'
$time[0]='2012-11-13T03:11:11.4504830Z'
$file[1]='E:\Downloads\test\file1'
$time[1]='2012-11-10T01:12:14.6126918Z'
$file[2]='E:\Downloads\test\file2'
$time[2]='2012-11-10T01:12:14.6646918Z'
$file[3]='E:\Downloads\test\file3'
$time[3]='2012-11-10T01:12:14.7276918Z'
$file[4]='E:\Downloads\test\cover.jpg'
$time[4]='2012-11-10T01:12:14.7886918Z'
$file[5]='E:\Downloads\test\OldTime.ps1'
$time[5]='2012-11-13T05:22:18.2124830Z'
$file[6]='E:\Downloads\test\SaveTime.ps1'
$time[6]='2012-11-13T05:44:22.8514830Z'
$file[7]='E:\Downloads\test\test.ps1'
$time[7]='2012-11-13T03:26:28.7084830Z'
$file[8]='E:\Downloads\test\test.time.ps1'
$time[8]='2012-11-13T05:32:51.8204830Z'
$file = New-Object string[] 11
$time = New-Object string[] 11
$file[0]='E:\Downloads\test\New Folder'
$time[0]='2012-11-13T03:11:11.4504830Z'
$file[1]='E:\Downloads\test\file1'
$time[1]='2012-11-10T01:12:14.6126918Z'
$file[2]='E:\Downloads\test\file2'
$time[2]='2012-11-10T01:12:14.6646918Z'
$file[3]='E:\Downloads\test\file3'
$time[3]='2012-11-10T01:12:14.7276918Z'
$file[4]='E:\Downloads\test\cover.jpg'
$time[4]='2012-11-10T01:12:14.7886918Z'
$file[5]='E:\Downloads\test\new 3.txt'
$time[5]='2012-11-13T06:47:05.4784830Z'
$file[6]='E:\Downloads\test\OldTime-record.ps1'
$time[6]='2012-11-13T05:50:11.7044830Z'
$file[7]='E:\Downloads\test\OldTime.ps1'
$time[7]='2012-11-13T05:22:18.2124830Z'
$file[8]='E:\Downloads\test\SaveTime.ps1'
$time[8]='2012-11-13T05:44:22.8514830Z'
$file[9]='E:\Downloads\test\test.ps1'
$time[9]='2012-11-13T03:26:28.7084830Z'
$file[10]='E:\Downloads\test\test.time.ps1'
$time[10]='2012-11-13T05:32:51.8204830Z'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
14975 次 |
| 最近记录: |