本文介绍了批处理文件来替换文件名中的空间凸显的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图取代下划线与空格部分文件名,例如:
I am trying to replace underscores in some file names with spaces, for example:
this_is_a_file.pdf
变成了:
this is a file.pdf
在Windows中使用批处理文件。
In Windows using a batch file.
我也发现了类似的问题,但它什么也没有代替空格:的
I have found a similar question, but it replaces spaces with nothing: How to remove spaces from file names (in bulk)
它可以被轻松地译做我想要什么?
Can it be easily translated to do what I want?
推荐答案
使用%文件:_ =%
重新present %文件%
用空格代替下划线。不幸的是这不会对变量所以如果你遍历文件,你必须使用一个中间变量工作。
Use %file:_= %
to represent %file%
with underscores replaced with spaces. Unfortunately this won't work on a for variable so if you're looping over files you have to use an intermediate variable.
@echo off
setlocal enabledelayedexpansion
for %%a in (*_*) do (
set file=%%a
ren "!file!" "!file:_= !"
)
这篇关于批处理文件来替换文件名中的空间凸显的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!