批次:从字符串中删除字符串 [英] Batch: Remove a string from a string

查看:135
本文介绍了批次:从字符串中删除字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有维基百科以下批处理脚本:

I have the following batch script from Wikipedia:

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

这里

我学到 的是 %%〜NF 只返回文件名不带扩展名。
现在我只是想删除(视频)从文件名( %%〜NF )。
我怎么能这样做呢?

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?

推荐答案

试试这个:

@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

这篇关于批次:从字符串中删除字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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