bat 批处理 批量调整 srt 字幕文件时间

本文介绍了如何创建和使用bat批处理文件Srt_time_one.bat和Srt_time_all.bat来批量调整srt字幕的时间,如整体提前或滞后。批处理文件需以ANSI编码保存,对GB2312编码友好,处理utf-8编码时需添加chcp 65001命令。注意批处理对特殊字符的支持有限。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先建立 Srt_time_one.bat 批处理文件, 用来调整 srt 字幕文件的总体时间,提前或滞后。

@echo off
title Srt_time_one_num
CLS
color 2

if "%~2" equ "" echo 错误: 应为 Srt_time_one.bat ^"test.srt^" 2 这样的格式&pause>nul&exit /b

set "inFile=%1"
set "inFile=%inFile:"=%"
set /a "t=%2"
for /f "delims=0123456789-" %%a in ("%t%") do if not "%%a"=="" echo 错误: 秒数&pause>nul&exit /b

echo "%inFile%"
if not EXIST "%inFile%" echo 文件 "%inFile%" 不存在&pause>nul&exit /b

type nul >"%inFile%__tmp.srt"

setlocal enabledelayedexpansion
for /f "usebackq delims=" %%a in ("%inFile%") do (
    set "str=%%a"    
    set "tmp=!str:~25,1!"    
    if defined tmp (
        if /i "!tmp!"=="," (
            set "bhms=!str:~17!"
            echo !bhms! | findstr /i "^[0-9]*:[0-9]*:[0-9]*,[0-9]*" >nul&& (
                set "ahms=!str:~0,8!"
                set "astr=!str:~8,4!"
                set /a "h1=1!ahms:~0,2!-100"
                set /a "m1=1!ahms:~3,2!-100"
                set /a "s1=1!ahms:~6,2!-100"
                set /a "ts=!h1!*3600+!m1!*60+!s1!+!t!"
                set /a "h1=!ts!/3600
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值