获取文件名批量循环 [英] Get filename in batch for loop
本文介绍了获取文件名批量循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下的for循环的批处理文件:
I have the following For loop in a batch file:
for /R c:\test\src %%i IN (*.*) DO (
MOVE %%i C:\test\destination
ECHO %%i
exit
)
在ECHO的结果输出整个文件路径例如: C:\\文件夹\\文件名
我需要呼应出只在文件名。是有一个特定的命令,它会给我的名?
谢谢!
The result of the ECHO outputs the entire file path Ex: C:\Foldername\Filename I need to ECHO out only the Filename.Is there a specific command which would give me the filename ? Thanks !
推荐答案
在命令扩展被启用(Windows XP和更新,大致),您可以使用语法%〜NF(其中F为变量,〜n是它的名字请求)只得到文件名。
When Command Extensions are enabled (Windows XP and newer, roughly), you can use the syntax %~nF (where F is the variable and ~n is the request for its name) to only get the filename.
FOR /R C:\Directory %F in (*.*) do echo %~nF
应该只呼应的文件名。
should echo only the filenames.
这篇关于获取文件名批量循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文