Windows批处理文件重命名 [英] windows batch file rename

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

问题描述

我有一些文件,如 AAA_a001.jpg BBB_a002.jpg CCC_a003 .JPG 在Windows 7
我试图用批量重命名这些文件,以 a001_AAA.jpg a002_BBB.jpg a003_CCC.jpg

刚换 _ 之间的内容。

我一直在寻找了一段时间,但仍然不知道如何做到这一点。
任何人都可以帮忙吗?
谢谢你。


解决方案

 关闭@echo
PUSHDpathToYourFolder||退出/ B
FOR / FEOL =:delims =%% f由于('。DIR / B / A-D * _ * JPG')做(
  FOR / F令牌= 1 * EOL = _ = delims _中(%% F)并仁%% F%% %% A〜NB _ %%一个%%〜xF的

POPD

请注意:这个名字是在 _ 中第一次出现分裂。如果一个文件被命名为part1_part2_part3.jpg,那么它​​将被重命名为part2_part3_part1.jpg

I have some file such as AAA_a001.jpg, BBB_a002.jpg, CCC_a003.jpg in Windows 7 and I'm trying to use batch to rename these file to a001_AAA.jpg, a002_BBB.jpg, a003_CCC.jpg.

Just to swap the content between _.

I have been searching for a while, but still don't know how to do this. Can anyone help? Thanks.

解决方案

@echo off
pushd "pathToYourFolder" || exit /b
for /f "eol=: delims=" %%F in ('dir /b /a-d *_*.jpg') do (
  for /f "tokens=1* eol=_ delims=_" %%A in ("%%F") do ren "%%F" "%%~nB_%%A%%~xF"
)
popd

Note: The name is split at the first occurrence of _. If a file is named "part1_part2_part3.jpg", then it will be renamed to "part2_part3_part1.jpg"

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

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