我有根文件夹的路径。我想在文件夹下得到扩展名为".txt“的文件名。
我的根路径是"D:\SVN\ISG-RMG\Vendorpayment2.0\Branches\VPSAPITest\TestResults".
在这个路径下有许多文件和子文件夹.
我希望在给定路径下搜索.txt文件,并希望将.txt文件名分配给批处理文件中的变量并回显其名称。
怎么做?
发布于 2020-08-10 12:05:47
来自cmd
@for /f "delims=" %i in ('dir /b /a-d "D:\SVN\ISG-RMG\Vendorpayment2.0\Branches\VPSAPITest\TestResults\*.txt"') do @set "result=%i"
在批处理文件中。
@echo off
for /f "delims=" %%i in ('dir /b /a-d "D:\SVN\ISG-RMG\Vendorpayment2.0\Branches\VPSAPITest\TestResults\*.txt"') do set "result=%%i"
echo %result%
发布于 2020-08-10 11:58:24
以下命令搜索/home/username/目录和所有子目录中的*.txt文件。
Linux(在我使用时,没有测试此命令):
dir /home/username/ *.txt
Linux命令:
find /home/username/ -name "*.txt"
https://stackoverflow.com/questions/63339574
复制相似问题