将文件拖放到批处理文件中

时间:2015-08-31 14:21:49

标签: batch-file

好的,我一直在寻找一个我理解但无处可去的答案。这是我在批处理文件中的第一次尝试。这是我的批次

@echo off
cd /d "%~dp0"
start " " "F:\PUBLIC\shared\Lathe\ScrewMills\ShopAccess\CNC Programs\AEI_Transfer.bat" "%~f1"
If exist *.000 mv *.000 *.456
DEL /Q "*.456" "F:\PUBLIC\shared\Lathe\ScrewMills\ShopAccess\CNC Programs\CURRENT CNC PROGRAM\AEI"
move /y "*.000" "F:\PUBLIC\shared\Lathe\ScrewMills\ShopAccess\CNC Programs\CURRENT CNC PROGRAM\AEI"
pause
exit /b

如果我删除的文件与批处理文件位于同一文件夹中但我需要从不同的文件夹中删除文件,它会起作用。 我知道这已被覆盖但我没有得到路径???

1 个答案:

答案 0 :(得分:0)

这是一个代码,演示用户如何将文件或文件名分别拖放到命令提示符窗口:

@echo off
setlocal EnableDelayedExpansion
set "FileName=""
echo Enter file name with path or drag ^& drop a file on prompt below and press ENTER.
echo.

rem Prompt user for file name. The user can drag and drop a file and
rem press key RETURN or ENTER to enter the file name with path.
set /P "FileName=File name: "

rem Remove all double quotes from file name using a replace with delayed expansion.
set "FileName=!FileName:"=!"

rem Has the user really entered a file name?
if not "!FileName!" == "" (
    echo.
    echo The file name is: !FileName!
    echo.
    pause
)
endlocal

要了解使用的命令及其工作原理,请打开命令提示符窗口,执行以下命令,并完全阅读为每个命令显示的所有帮助页面。

  • if /?
  • set /?