Java教程

Bat

本文主要是介绍Bat,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

浮生若梦——Galois21 Windows下批量对文件重命名             http://blog.galois21.com/archives/712

一.批量清除文件名中含有空格的文件

@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%i in ('dir /s/b *.*') do (
set "foo=%%~nxi"    
set foo=!foo: =!    
set foo=!foo: =!    
ren "%%~fi" "!foo!"
)
pause

 二.批量去除文件名中的某些字符串

@echo off
set /p str1= Please enter the file (folder) name string (interchangeable space) to be replaced:
set /p str2= Please enter the name string of the replaced file (folder) (Enter directly if removed):
echo.
echo Please wait while changing the name of the file (folder)!!!!
for /f "delims=" %%a in ('dir /s /b ^|sort /+65535') do (
if "%%~nxa" neq "%~nx0" (
set "file=%%a"
set "name=%%~na"
set "extension=%%~xa"
call set "name=%%name:%str1%=%str2%%%"
setlocal enabledelayedexpansion
ren "!file!" "!name!!extension!" 2>nul
endlocal
)
)
exit

  

  

这篇关于Bat的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!