代码之家  ›  专栏  ›  技术社区  ›  ChopOMatic

在批处理文件中使用时发生删除引发错误

  •  0
  • ChopOMatic  · 技术社区  · 3 年前

    我需要一个批处理文件,将拉文件名,路径,从一个文本文件;然后将文件复制到外部驱动器,然后安全地删除该文件。除了sdelete之外,这个批处理文件的所有功能都有效。它抛出一个错误,显然表明路径和文件名没有括在引号中。但是,正如您在批处理文件中看到的,它是。完全相同的文件使用 德尔 而不是 删除 .有什么想法吗?

    enter image description here

    @echo off
    
    set Source=D:\files.txt
    set Destination=D:\Reclamation
    
    SetLocal EnableDelayedExpansion
    
    for /f "tokens=* delims=" %%a in ('type "%Source%"') do (
     IF not exist "%Destination%%%~pa" md "%Destination%%%~pa"
     xcopy /shrkvy "%%a" "%Destination%%%~pa"
     IF NOT !ErrorLevel! EQU 0 (echo "%%a">>"Errors.txt") else (sdelete64 -q -z "%%a")
    )
    
    1 回复  |  直到 3 年前
        1
  •  1
  •   Magoo    3 年前

    来自微软的文档: Sdelete documentation

    Usage: sdelete [-p passes] [-r] [-s] [-q] <file or directory> [...]
    sdelete [-p passes] [-z|-c [percent free]] <drive letter [...]
    

    所以 -q 未记录,但似乎与 -z

    -z 需要开车 ,而不是目标文件/目录。