Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 将带有通配符的绝对文件路径设置为CMD.bat文件中的变量_Batch File_Cmd - Fatal编程技术网

Batch file 将带有通配符的绝对文件路径设置为CMD.bat文件中的变量

Batch file 将带有通配符的绝对文件路径设置为CMD.bat文件中的变量,batch-file,cmd,Batch File,Cmd,我试图将批处理脚本中的一个变量设置为某个文件的绝对路径,但是文件名不是常量 例如,文件路径类似于: C:\someFolder\anotherFolder\TestFile_%.txt set VAR="C:\someFolder\anotherFolder\TestFile_%.txt" echo VAR is: %VAR% 其中%可以是任意数量的字符。这个目录中只有一个文件的命名约定为TestFile*.txt,所以我不必担心多个匹配 如何将脚本中的某些变量设置为此绝对文件路径?比如:

我试图将批处理脚本中的一个变量设置为某个文件的绝对路径,但是文件名不是常量

例如,文件路径类似于:

C:\someFolder\anotherFolder\TestFile_%.txt
set VAR="C:\someFolder\anotherFolder\TestFile_%.txt"
echo VAR is: %VAR%
其中%可以是任意数量的字符。这个目录中只有一个文件的命名约定为TestFile*.txt,所以我不必担心多个匹配

如何将脚本中的某些变量设置为此绝对文件路径?比如:

C:\someFolder\anotherFolder\TestFile_%.txt
set VAR="C:\someFolder\anotherFolder\TestFile_%.txt"
echo VAR is: %VAR%
输出应该在哪里:VAR是C:\someFolder\anotherFolder\TestFile_1234.txt

对于C:\someFolder\anotherFolder\TestFile.u*.txt中的%%A,请设置var=%A

使用其他字符和TXT扩展名搜索一个名为TestFile_uu.的文件

尝试以下操作:在C:\someFolder\anotherFolder\TestFile_*.TXT中搜索%I,或者在批处理文件中使用%%而不是%%…