命令行批从它的文件名中删除_ [英] command line batch remove _ from its file name
本文介绍了命令行批从它的文件名中删除_的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有多个文件,并想重新命名其文件。结果
例如,我有
I have multiple files and would like to rename its file.
For example, I have
2014_19_24_english_test.doc
"2014_19_24_english_test.doc"
和将其更改为
2014 19 24英语Test.doc的
"2014 19 24 english test.doc"
这是我迄今所做的:
for /f "delims=" %%f in ('dir /b *.hwp') do ren "%%~f" "%%~nf:_= %%~xf"
这是行不通的。任何帮助将是AP preciated,
and this is not working. Any help would be appreciated,
克里斯
推荐答案
您不能使用的子字符串替换语法
变量,所以你需要一个临时变量来做到这一点采用延迟扩展:
You cannot use the substring replacement syntax with for
variables, so you need an interim variable to do that, using delayed expansion:
setlocal EnableDelayedExpansion
for /f "delims=" %%f in ('dir /b *.hwp') do (
set "FNAME=%%~nf"
ren "%%~ff" "!FNAME:_= !%%~xf"
)
endlocal
这篇关于命令行批从它的文件名中删除_的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文