【发布时间】:2019-11-15 03:15:37
【问题描述】:
有 2 个驱动器:
- 网络驱动器,报告所在的位置
- 7zip 所在的本地磁盘。
另外,我们有很多用户,每个人都用不同的字母映射网络驱动器。因此,每个人的举报途径都不尽相同。
脚本和报告位于同一文件夹中。 尝试创建 script.bat 以在网络驱动器上存档报告。这是我所拥有的:
@echo off
::set a path to network shared directory
pushd \\IP_address\path_to_reports
set BEpath= %cd%
:: Move files to temporary directory FilesToZip
mkdir "%BEpath%\FilesToZip"
move %BEpath%\report_Germany_??_%1_??.txt %BEpath%\FilesToZip\
:: Archive files
cd /d "C:\Program Files\7-Zip"
7z a -t7z "%BEpath%\archive.7z" "%BEpath%\FilesToZip\*.txt"
如果我只使用CD \\server\path 而不是pushd \\IP_address\path_to_reports 它会报错
CMD does not support UNC paths as current directories.
看起来它无法从 C:\ 驱动器压缩到网络驱动器并给出错误:
7-Zip 19.00 (x64) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21
Scanning the drive:
WARNING: The filename, directory name, or volume label syntax is incorrect.
Z:
0 files, 0 bytes
Creating archive: Z:\path\archive.7z
Add new data to archive: 0 files, 0 bytes
Scan WARNINGS for files and folders:
Z: : The filename, directory name, or volume label syntax is incorrect.
----------------
Scan WARNINGS: 1
Error:
cannot open file
Z:\path\archive.7z
The filename, directory name, or volume label syntax is incorrect.
你能建议一下,怎么做吗?
谢谢
【问题讨论】:
标签: batch-file cmd