开发者

Batch: Remove a string from a string

I have the following batch script from Wikipedia:

@echo off
    for /R "C:\Users\Admin\Ordner" %%f in (*.flv) do (
    echo %%f
)
pause

I learned here that %%~nf returns just the filename开发者_如何转开发 without the extension. Now I just wanted to remove (Video) from the filenames (%%~nf). How could I do that?


Try this:

@echo off
for /R "C:\Users\Leniel\Desktop\BatchTest" %%f in (*.flv) do (
    call :Sub %%~nf 
    )

:Sub
set str=%*
set str=%str:(Video)=%
echo %str%
pause

Take a look at the following link to learn about removing a substring using string substitution:

http://www.dostips.com/DtTipsStringManipulation.php#Snippets.Remove

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜