某些字符后批量重命名文件 [英] Batch renaming files after certain character

查看:58
本文介绍了某些字符后批量重命名文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一堆视频文件,其名称如下:

I have a bunch of video files with names like so:

6592110904-Ivory-2.mp4
6592280588-Cornflower.mp4
6592321696-Ballet Pink.mp4

我想重命名它们以消除第一个连字符之后的所有内容,因此它们最终像:

I want to rename them to get rid of everything after the first hyphen so they end up like:

6592110904.mp4
6592280588.mp4
6592321696.mp4

我该怎么做?

推荐答案

请将下面的代码放在bat文件中,并将其放在包含mp4文件的目录中.在运行真正的重命名之前,请在移动"之前删除"echo".请重命名,请谨慎(理论上),不同文件的名称可能相同.系统会提示您确认是否要覆盖旧文件.

Please put the code below in a bat file, place it in directory with mp4 files. Before running real renaming, please remove "echo" before "move". please be carefull with renaming bacause (theoretically) it is possible to have same name for different files.You'll be prompted to confirm if you want to override the old one.

代码在破折号后分割每个文件名,并使用第一项重命名该文件.祝你好运.

Code splits each filename after dash and renames the file taking first item. Good luck.

@echo off

for /F "tokens=1,* delims=-" %%a in ('dir /A-D /B "*.mp4"') do (
    echo move "%%a-%%b" "%%a%%~xb"
)

这篇关于某些字符后批量重命名文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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