如何仅在"for"批处理命令中获取文件名而不是文件扩展名 [英] How to get only file name in 'for' batch command and not file extension

查看:135
本文介绍了如何仅在"for"批处理命令中获取文件名而不是文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用此代码将视频上传到YouTube时,被命名的标题的文件扩展名结尾(在本例中为.mp4)

When using this code to upload video's to YouTube, the title that gets named has the file extension at the end (in this case .mp4)

for %%f in (*.mp4) do python --file="%%f" --title="%%f"

推荐答案

对(* .csv)中的%% f使用做回显"%%〜nf"

use for %%f in (*.csv) do echo "%%~nf"

有关更多信息,请对/?做一个..这是您希望看到的部分

for more info do a for /? .. this is the part that you would liek to see

In addition, substitution of FOR variable references has been enhanced.
You can now use the following optional syntax:
%~I         - expands %I removing any surrounding quotes (")
%~fI        - expands %I to a fully qualified path name
%~dI        - expands %I to a drive letter only
%~pI        - expands %I to a path only
%~nI        - expands %I to a file name only
%~xI        - expands %I to a file extension only
%~sI        - expanded path contains short names only
%~aI        - expands %I to file attributes of file
%~tI        - expands %I to date/time of file
%~zI        - expands %I to size of file
%~$PATH:I   - searches the directories listed in the PATH
               environment variable and expands %I to the
               fully qualified name of the first one found.
               If the environment variable name is not
               defined or the file is not found by the
               search, then this modifier expands to the
               empty string

这篇关于如何仅在"for"批处理命令中获取文件名而不是文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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