Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.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 批量复制名称为通配符的excel文件不会';不要复制文件中的内容_Batch File - Fatal编程技术网

Batch file 批量复制名称为通配符的excel文件不会';不要复制文件中的内容

Batch file 批量复制名称为通配符的excel文件不会';不要复制文件中的内容,batch-file,Batch File,我有这个批处理文件,可以将一个公共目录中的文件复制并重命名为另一个公共目录。文件大小通常约为1600kb,但复制的文件只有1kb。如果我将名称中的通配符更改为真实名称,则会复制整个文件。问题是每次更新后文件名都会更改,例如名称3.25.13,名称4.12.13 e.t.c,因此我必须使用通配符,除非您有其他方式告诉我,这将非常感谢。以下是批次代码: c: cd U:\Sourcing\Vendor Demand Planning\Master CPFR\ copy "U:\Sourcing\V

我有这个批处理文件,可以将一个公共目录中的文件复制并重命名为另一个公共目录。文件大小通常约为1600kb,但复制的文件只有1kb。如果我将名称中的通配符更改为真实名称,则会复制整个文件。问题是每次更新后文件名都会更改,例如名称3.25.13,名称4.12.13 e.t.c,因此我必须使用通配符,除非您有其他方式告诉我,这将非常感谢。以下是批次代码:

c:
cd U:\Sourcing\Vendor Demand Planning\Master CPFR\

copy "U:\Sourcing\Vendor Demand Planning\Master CPFR\Master CPFR*.xlsx" "U:\Sourcing\Vendor Demand Planning\Pricing Project\Master CPFR.xlsx"

您可以使用
dir/o:-d
获取最新的匹配文件

cd /d "U:\Sourcing\Vendor Demand Planning\Master CPFR\"

for /f "delims=" %%I in ('dir /b /o:-d "Master CPFR*.xlsx"') do (
    copy "%%I" "..\Pricing Project\Master CPFR.xlsx"
    exit /b
)

如果脚本还有更多内容,只需将
exit/b
替换为
goto标签
,并将
:标签
放在
for
循环后的某个位置。您只希望循环执行一次,然后中断。

是否收到错误消息?工作正常。谢谢。@user2220670-太好了!如果你同意这样做是合适的,请考虑。