根据分辨率使用批次重命名我的视频文件 [英] Renaming my video files as per the resoltuion using batch

查看:456
本文介绍了根据分辨率使用批次重命名我的视频文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想根据他们所在的分辨率重新命名我的视频文件,例如1080p中的视频bla bla.mp4,我想将其重命名为bla bla [H.264 1080p] 。脚本应该能够自动地检测视频的分辨率,并且如果文件已经被重命名,它不应该重命名它。我不能找到一种方法来检查分辨率,所以我试图使用这个对于1080p文件:

I would like to rename my video files as per the resolution they are in, e,g for a video 'bla bla.mp4' in 1080p, I would like to rename it to 'bla bla [H.264 1080p]. The script should automatically be able to detect the resolution of the video, and also if the file has been already renamed it should not rename it.I wasn't able to find a way to check for the resolution, so I tried to use this for 1080p files:

    FOR /r %%a in (*.mp4) DO (IF EXIST *[H.264*.mp4 (
    ECHO Already done) 
    ELSE (
    REN "%%~a" "%%~na [H.264 1080p].mp4"))

但是它做的是一次又一次检查同一个文件,它已经被重命名,因此回复总是完成。

But what it does is it checks for the same file again and again which has already been renamed and therefore the reply always is 'Already done'.

推荐答案

此问题超出了SO问题的范围。

This question is beyond the scope of an SO question. Nevertheless I will answer it, because today is sunday.


  • 下载并安装 mediainfo 命令行版本

  • 将路径添加到 mediainfo 二进制文件复制到系统或用户 PATH 环境变量

  • 复制重命名脚本,到您的视频文件夹,在 rename 命令之前有一个安全 echo ,如果输出看起来很好, li>
  • 脚本测试已经存在的文件(由Peter Wright提出)

  • download and install mediainfo command line version
  • add the path to the mediainfo binaries to your system or user PATH environment variable
  • copy the rename script, replace the path to your video folder, there is a safety echo before the rename command, remove it if the output looks good
  • the script tests for already-exists and already-processed files (suggested by Peter Wright)

重命名脚本:

@echo off & setlocal
cd X:\video\path
for /f "delims=" %%i in ('dir /b /a-d *.mp4') do (
    set "fnameo=%%~ni"
    set "fnamee=%%~xi"
    set "Height="
    for /f "delims=" %%j in ('mediainfo "--Inform=Video;%%Height%%" "%%~i"') do set "Height=%%j" 
    setlocal enabledelayedexpansion
    call set "selftest=%%fnameo:[H.264 !Height!p]=%%"
    if "!selftest!" equ "!fnameo!" if not exist "!fnameo! [H.264 !Height!p]!fnamee!" (
        echo rename "!fnameo!!fnamee!" "!fnameo! [H.264 !Height!p]!fnamee!"
    )
    endlocal
)






输出示例:


output example:


rename "Handbrake.0.9.8.mp4" "Handbrake.0.9.8 [H.264 800p].mp4"
rename "Hybrid.2012.10.21.1.mp4" "Hybrid.2012.10.21.1 [H.264 800p].mp4"
rename "Womble.mp4" "Womble [H.264 1080p].mp4"

这篇关于根据分辨率使用批次重命名我的视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆