我有一些困难与“for / f”无法find具有特定名称的文件。 当该文件或path包含空格时,该站点上的许多用户都遇到了这个问题,但这里并不是这种情况。 简单的例子,名为“test4.cmd”的batch file:
@echo off set ln=%1 if exist 2013_10_23_Cal_Curve.txt echo The first file exists. if exist ~temp1.txt echo The second file exists. for /f "skip=%ln% tokens=2" %%a in (2013_10_23_Cal_Curve.txt) do echo Found the first file. for /f "skip=%ln% tokens=2" %%a in (~temp1.txt) do echo Found the second file.
输出:
C:\ Users \ wnc7 \ Desktop \ jmp_test_data> test4 1 第一个文件存在。 第二个文件存在。 系统找不到文件2013_10_23_Cal_Curve.txt。 find第二个文件。 find第二个文件。 find第二个文件。 *(预计输出继续第二个文件....)*
findtr等其他命令可以find文件,但是/ f找不到。 然而,/ f可以find〜temp1.txt以相同的格式写在同一个目录中。
我已经尝试过“usebackq”并将文件名放在引号中,无济于事。 任何帮助表示赞赏。
麦克风
该文件被另一个进程读取阻止。 如果它不能被共享,它是存在的,并且可以被找到,但是for /f
不能处理它。 尝试type file
或delete file
,而不是命令,那么错误将是系统无法访问该文件,因为它正在被另一个进程使用。