不存在文件名时批处理文件不显示错误

时间:2019-03-31 00:17:16

标签: batch-file command-line copy

我刚开始批量处理,只是很好奇为什么我的.bat文件接受输入,但是不显示错误或其他任何内容,它只是关闭了。也许是我想念的东西。谢谢!

@echo off



REM Clear the screen
REM ------------------------------------------------------
cls


REM Getting user input
REM ------------------------------------------------------
SET /p FilesToCopy="Please enter a file to copy!: "


REM 1. Copies files to myTemp
REM ------------------------------------------
IF EXIST "%FilesToCopy%" (

  xcopy %FilesToCopy% C:\myTemp /E

  ECHO FILE [%FilesToCopy%] are being copied!

REM 2. Displays error if not found
REM ------------------------------------------
) ELSE (

  ECHO Sorry but there was a issue copying [%FilesToCopy%]..

)

1 个答案:

答案 0 :(得分:0)

问题是我没有从本地文件夹通过cmd提示符本身运行批处理文件。