开发者

windows script for delete white space from file name

I wrote a script that clear white space开发者_JS百科s and write it to the console, but infact do nothing to file name -

@echo off&setlocal EnableDelayedExpansion
for /f "tokens=*" %%A in (
'dir C:\Inetpub\ftproot\MG_REPORTS\MG_PRO_\Network\Frank\ "* *"'
) do (set XX=%%~nxA)&echo ren "%%A"  "!XX: =!"

regards,

shamie


Your for loop only sets XX to the last file name encountered. Also it probably loops over all files in the given directory and all file names containing spaces in the current working directory.

I'd do it the following way:

setlocal enabledelayedexpansion
for %%f in (C:\Inetpub\ftproot\MG_REPORTS\MG_PRO_\Network\Frank\*) do (
   set "FN=%%~nxf"
   set "FN=!FN: =!"
   ren "%%f" "!FN!"
)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜