批处理:从字符串中删除字符串

发布于 2024-09-08 20:38:07 字数 337 浏览 1 评论 0原文

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

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

这里了解到 %%~nf 仅返回不带扩展名的文件名。 现在我只想从文件名中删除 (Video) (%%~nf)。 我怎么能这么做呢?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我ぃ本無心為│何有愛 2024-09-15 20:38:07

试试这个:

@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

查看以下链接,了解如何使用字符串替换删除子字符串:

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文