如何批量重命名子文件夹中的文件 - 使用CMD命令提示符 [英] How to bulk rename files within subfolders - using CMD command prompt

查看:965
本文介绍了如何批量重命名子文件夹中的文件 - 使用CMD命令提示符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对命令提示符(Windows)很新,但是我使用它来做一些文件扩展名更改,这是非常有帮助的。我不知道编码,所以我只是离开我已经阅读,但我正在寻找一个命令行,我似乎找不到任何地方。我有文件夹,里面的文件夹是70个子文件夹,每个标记一个从1-70的数字。在这些子文件夹内是大约20 png的图片文件,目前编号为一个从1到20之间的一个数字png格式。我正在寻找一个命令行将每个文件从其原始名称重命名为文件夹名称(页码).png

I am quite new to Command Prompt (Windows), however I have used it to do some file extensions changing and it is extremely helpful. I know nothing on coding, and so i am simply going off what I have read about but I am looking for a command line that I cant seem to find anywhere. I have folder, and inside that folder are 70 sub folders each labelled by a number from 1-70. Inside these subfolders are roughly 20 png picture files, that are currently numbered by a number from 1-20 in png format. I am looking for a command line to rename each file from its original name to "folder name (page number).png"

例如,我有一个文件夹名为'68 ',里面的文件夹是1.png,2.png,3.png。我想命令行将1.png和2.png等更改为68(1).png和68(2)。 png,注意括号和文件夹名称之间的空格。对不起,如果我有困惑,但我会真的很感激它,我有一些非常有用的和快速的答案从StackOverflow之前

For example, I have folder called '68' and inside that folder is 1.png, 2.png, 3.png. I want the command line to change that 1.png and 2.png etc... to 68 (1).png and 68 (2). png, noticing the space between the bracket and the folder name. Sorry if i have made it confusing but I would really appreciate it and I have got some very helpful and quick answers from StackOverflow before

谢谢,如果你能够帮助我,

Thankyou if you are able to help me, as i am completely hopeless on this matter.

推荐答案

只运行一次 - 从包含70个文件夹的文件夹启动它。 / p>

Only run this once - launch it from the folder containing the 70 folders.

@echo off
for /f "delims=" %%a in ('dir /ad /b') do (
pushd "%%a"
for /f "delims=" %%b in ('dir /a-d /b') do ren "%%b" "%%a (%%~nb)%%~xb"
popd
)

这篇关于如何批量重命名子文件夹中的文件 - 使用CMD命令提示符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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