批量获取文件名 for 循环 [英] Get filename in batch for loop

查看:36
本文介绍了批量获取文件名 for 循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在批处理文件中有以下 For 循环:

I have the following For loop in a batch file:

for /R c:	estsrc %%i IN (*.*) DO (
MOVE %%i C:	estdestination
ECHO %%i
exit
)

ECHO 的结果输出整个文件路径 Ex:C:FoldernameFilename我只需要回显文件名.是否有特定的命令可以给我文件名?谢谢!

The result of the ECHO outputs the entire file path Ex: C:FoldernameFilename 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

应该只回显文件名.

这篇关于批量获取文件名 for 循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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