我正在尝试生成临时文件夹和文件名。然后想删除并创建临时文件夹。稍后一些文件将被复制到该临时文件夹中。这是我的代码......(在同行代码的帮助下)
echo off
Setlocal EnableDelayedExpansion
set "ZipFileName = png_%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%.zip"
set "TEMPFOLDER = %date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%"
echo !TEMPFOLDER!
set "TEMPDIR =C:\Temp\%ZipFileName%"
rmdir "%TEMPDIR%"
mkdir "%TEMPDIR%"
copy *.png "%TEMPDIR%"
谢谢,
答案 0 :(得分:0)
你在wromg地方使用“并使用很多空格,特别是你的变量名称。
set var = somevar with a space
set var= somvar withoit a space
现在你有两个vars,名为var[space]
,一个名为var
。您可以使用set v
列表环境变量验证bu。
set ZipFileName=png_%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%.zip
set TEMPFOLDER="%date:~10%%date:~4,2%%date:~7,2%%time:~0,2%%time:~3,2%"
echo !TEMPFOLDER!
set TEMPDIR="C:\Temp\%ZipFileName%"
rmdir %TEMPDIR%
mkdir %TEMPDIR%
copy *.png %TEMPDIR%