cmd窗口用下划线替换空格 [英] cmd windows replace spaces with underscores

查看:348
本文介绍了cmd窗口用下划线替换空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重命名文件夹中的所有文件(所有.exe文件)。我想用下划线替换所有空格,例如:qwe qwe qwe asd.exe到qwe_qwe_qwe_asd.exe。

I'm trying to rename all the files inside a folder (all .exe files). I want to replace all the spaces with underscores, e.g: "qwe qwe qwe asd.exe" to "qwe_qwe_qwe_asd.exe".

我需要使用命令行。我尝试了很多可能的解决方案,我在互联网上,甚至在这个网站,但我不能使它的工作。

I need to do this using the command line. I tried a lot of possible solutions I found on internet and even on this site, but I can't make it work.

我也需要这样做在一单线/一个命令,但我会接受所有的工作答案。

I also need to do this in "one single line" / "one command", but I'll accept all the working answers..

谢谢!

推荐答案

一个线索

cmd /e:on /v:on /c "for %f in ("* *.exe") do (set "n=%~nxf" & set "n=!n: =_!" & ren "%~ff" "!n!" )"

生成一个cmd实例,启用扩展和延迟扩展,对于每个exe文件,名称,用下划线替换空格,并使用新名称

Spawn a cmd instance, with extensions and delayed expansion enabled, and for each exe file with spaces in name, replace spaces with underscores and rename the file with the new name

这篇关于cmd窗口用下划线替换空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆