批量重命名文件与文件夹名称和序列号 - 发送菜单 [英] Batch rename files with the folder name and sequence number - Send To Menu
问题描述
我有一个名为销售的文件夹。我该文件夹中有imgxy.jpg,imgab.jpg等。当我右键单击该文件夹,销售和发送到rename.bat文件(我已经复制的rename.bat文件到 C:\\ Documents和Settings \\用户名\\发送到)我想在文件销售文件夹更改为sales1.jpg,sales2.jpg等等。这种行为应该是什么我发送给此.bat文件属实。下面code是在Windows 7昨晚正常工作。现在我嗡了Windows XP SP3,它行的事工作。它试图在文件夹的 * C中重命名文件:\\ Documents和Settings \\用户名*
请帮忙rename.bat文件code以下
@ECHO OFF
SETLOCAL enabledelayedexpansion
设置文件夹名称=%1
对于%% i的(%巴%)并设置栏= %%〜に
FOR在(%巴%)/ D %%#DO(
PUSHD%%#
在FOR(*)%% @ DO(
集/一个增量+ = 1
回声仁:\\ %%〜N#\\ %% @%%〜N#INC %%〜点¯x@!
仁%% @%%〜N#!INC!%%〜点¯x@
)
POPD
)
测试此 - 它接受一个文件夹,而不是文件,而是你在你的问题中提到的文件夹
不要把它叫做 rename.bat
,因为改名
是一个内部命令。
@ECHO OFF
SETLOCAL enabledelayedexpansion
PUSHD%〜1
设置INC = 0
FOR / Fdelims =%%一个在('DIR / B / A-D')DO(
集/ A INC + = 1
回声任志强:!%%一个%〜N1 INC %%〜XA
仁%%一个%〜N1!INC!%%〜XA
)
POPD
I have a folder called sales. I have imgxy.jpg, imgab.jpg etc in that folder. When I right click the sales folder and send to rename.bat file (I have already copied the rename.bat file into c:\documents and settings\username\send To) I want the files in the sales folder to change to sales1.jpg, sales2.jpg etc. This behaviour should be true for anything I send to this .bat file. The following code was working properly on windows 7 last night. Now I am om windows xp sp3 and it doest work. It is trying to rename files in the folder *c:\documents and settings\username*
Please help rename.bat file code below
@ECHO OFF
setlocal enabledelayedexpansion
set foldername=%1
for %%i in (%bar%) do set bar=%%~ni
FOR /D %%# in (%bar%) DO (
PUSHD "%%#"
FOR %%@ in ("*") DO (
set /a "inc+=1"
Echo Ren: ".\%%~n#\%%@" "%%~n#!inc!%%~x@"
Ren "%%@" "%%~n#!inc!%%~x@"
)
POPD
)
Test this - it accepts a folder, not files, but you mentioned folders in your question.
Don't call it rename.bat
because rename
is an internal command.
@ECHO OFF
setlocal enabledelayedexpansion
PUSHD "%~1"
set inc=0
FOR /f "delims=" %%a in ('dir /b /a-d') DO (
set /a inc+=1
Echo Ren: "%%a" "%~n1!inc!%%~xa"
Ren "%%a" "%~n1!inc!%%~xa"
)
POPD
这篇关于批量重命名文件与文件夹名称和序列号 - 发送菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!