查找并没有延伸重命名文件? [英] Find and rename files with no extention?
问题描述
所以,我有不带扩展名一堆文件。我想写一个Windows批处理脚本,将:
So, I've got a bunch of files with no extension. I want to write a windows batch script that will:
- 找到的文件不带扩展名(在指定的文件夹中)
- .bla添加到文件名末尾
我这样一个窗口批处理脚本小白我甚至不知道从哪里开始。建议?
I'm such a windows batch script noob I don't even know where to start. Suggestions?
推荐答案
有关Windows批处理文件,这将重命名为不带扩展名的.bla只有扩展名的文件:
For windows batch files, this will rename only files with no extension to the .bla extension:
rename *. *.bla
注意,第一个参数是一个明星,一个点:*
Notice the first argument is a star and a dot: *.
第二个参数是:* .bla
The second argument is: *.bla
启动点(。*)重新组合presents文件,在这种情况下没有扩展名。
The start dot (*.) combination represents files with no extensions in this context.
在
06/21/2009 11:57 PM 6 test
06/21/2009 11:57 PM 7 test.exe
06/21/2009 11:57 PM 7 test2
在
06/21/2009 11:57 PM 6 test.bla
06/21/2009 11:57 PM 7 test.exe
06/21/2009 11:57 PM 7 test2.bla
附加说明:与此相反的命令行都会.bla文件重命名为无扩展名的文件。
Additional note: The opposite commandline would rename all .bla files into no extension files.
修改
有关递归重命名与整个子目录没有扩展名的文件(不支持路径空格):
For recursively renaming files with no extension across subdirectories (doesn't support spaces in paths):
@echo off
FOR /F %%i in ('dir /b/s/A-d') DO (
if "%%~xi" == "" rename "%%~fi" "%%~ni.bla"
)
EDIT2:
有关递归重命名与整个子目录没有扩展名的文件(支持路径空格):
For recursively renaming files with no extension across subdirectories (supports spaces in path):
@echo off
for /f "tokens=* delims= " %%i in ('dir /b/s/A-d') DO (
if "%%~xi" == "" rename "%%~fi" "%%~ni.bla"
)
这篇关于查找并没有延伸重命名文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!