如何在文件夹重命名文件使用批处理文件来FOLDERNAME [英] How to rename files in folders to foldername using batch file
问题描述
结果
可以在任何你帮我一个问题,我有很多同名的,摆在sperate文件夹中的文件。结果
该文件夹的名称均带有数字,但里面的文件被命名为index.XXXX - 其中XXXX可能是.JPG或.html或.pdf格式结果
我想提出一个程序,可所有的索引文件重命名为相同的名称,它们被放置在文件夹中。结果
该文件夹名为6位数字 - 所有不同的结果。
在此之后希望已经做了,那么我想所有的重命名的文件移动到新的单个文件夹中,这样它会更容易让我看到了全部内容。结果期待读你的答案。
@回响FOR / D / R %%#中(*)DO(
PUSHD%%#
FOR %% @在(指数*)DO(
回声仁:\\ %%〜N#\\ %% @%%〜N#%%〜点¯x@
仁%% @%%〜N#%%〜点¯x@
)
POPD
)暂停和放大器;退出
测试文件夹结构:
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123321
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123321 \\ Index.txtC:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123456
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123456 \\的index.phpC:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123456 \\ 000000
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 123456 \\ 000000 \\ Index.cssC:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 654321
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 654321 \\ index.html在C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 654321 \\ 666999
C:\\用户\\ Administrador \\桌面\\努埃瓦carpeta(3)\\ 654321 \\ 666999 \\ Index.jpg
输出:
任志强:\\ 123321 \\ Index.txt123321.txt
任志强:\\ 123456 \\的index.php123456.php
任志强:\\ 654321 \\ index.html在654321.html
任志强:\\ 000000 \\ Index.css000000.css
任志强:\\ 666999 \\ Index.jpg666999.jpg
Could any of you help me with a problem I have with a lot of files with the same name, placed in sperate folders.
The folders are named with numbers, but the files inside are named index.XXXX - where XXXX could be .jpg or .html or .pdf.
I would like to make a 'program' that can rename all the 'index' files to the same name as the folder they are placed in.
The folders are named with 6 digit numbers - all different.
After this hopefully has been done, then I would like to move all the renamed files to a new single folder, so it will be easier for me to see the whole content.
Looking forward to reading your answers.
@Echo OFF
FOR /D /R %%# in (*) DO (
PUSHD "%%#"
FOR %%@ in ("index*") DO (
Echo Ren: ".\%%~n#\%%@" "%%~n#%%~x@"
Ren "%%@" "%%~n#%%~x@"
)
POPD
)
Pause&Exit
Tested folder structure:
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123321
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123321\Index.txt
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123456
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123456\Index.php
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123456\000000
C:\Users\Administrador\Desktop\Nueva carpeta (3)\123456\000000\Index.css
C:\Users\Administrador\Desktop\Nueva carpeta (3)\654321
C:\Users\Administrador\Desktop\Nueva carpeta (3)\654321\Index.html
C:\Users\Administrador\Desktop\Nueva carpeta (3)\654321\666999
C:\Users\Administrador\Desktop\Nueva carpeta (3)\654321\666999\Index.jpg
Output:
Ren: ".\123321\Index.txt" "123321.txt"
Ren: ".\123456\Index.php" "123456.php"
Ren: ".\654321\Index.html" "654321.html"
Ren: ".\000000\Index.css" "000000.css"
Ren: ".\666999\Index.jpg" "666999.jpg"
这篇关于如何在文件夹重命名文件使用批处理文件来FOLDERNAME的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!