批处理 - 为什么7zip命令工作不正常?

时间:2016-08-11 12:07:57

标签: batch-file

这是我的代码:

net use v: \\kimezgls-rez\arxiv_mppi                    
net use w: \\###.###.#.##\Protokoliem\KIMEZGLS-REZ_mppi 
cls
cd V:\
if not exist "V:\01_2016" mkdir "V:\01_2016"
pause
ECHO Folder is Created!
ECHO Moving Files...
MOVE "V:\??_01" "V:\01_2016"
ECHO Creating Backup!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
for /d %%X in (01_2016) do "C:\Program Files\7-Zip\7z.exe" a "%%X.7z" "%%X\"
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

ECHO Please wait few seconds... 
ECHO Backup is Created!
ECHO Sending Backup to ###.###.#.##\Protokoliem\KIMEZGLS-REZ_mppi
MOVE "V:\01_2016.7z" "w:\"
pause
cls
pause
GOTO MENU

我正在尝试制作脚本,即创建目录,将其命名为01_2016,并将所有文件放在其中,其中名称以_01结尾。然后存档文件夹01_2016并发送到另一个网络文件夹。 一切顺利,脚本开始存档文件夹01_2016,但不能。

Scanning the drive:
WARNING: The system cannot find the file specified.
01_2016
0 files, 0 bytes
Creating archive: 01_2016.7z
Items to compress: 0
Files read from disk: 0
Archive size: 32 bytes (1 KiB)
Scan WARNINGS for files and folders:
01_2016 : The system cannot find the file specified
----------------
Scan WARNINGS: 1

由于某种原因,它会在我的桌面上保存空的.zip文件夹。在解析整个代码时,我得出结论,这个命令只是不想让我成功运行脚本的事情。

感谢您的帮助

1 个答案:

答案 0 :(得分:2)

我想问题是CD V:\还不够。如果您在C:\ CD V:\,则不会将范围移至V:。要实现此目的,您必须将/d开关添加到CD命令:

...
cd /d V:\
...