cd %~dp0 意思是跳转到当前bat文件路径,这样很好的解决了更好文件夹出现找不到路径的问题
将bat文件放置于D:\develop\study\ScrapyObject\Grain目录下:
cd D:\develop\study\ScrapyObject\Grain\Grain\spiders 等价于 cd %~dp0Grain\spiders
@echo off
:loop
set /p a=确定要执行文件比较功能吗?(1继续,0退出)
if /i '%a%'=='1' goto continue
if /i '%a%'=='0' goto end
echo 输入有误,请重新输入:&&goto loop
:continue
cd %~dp0
start python 文件比较优化精简版.py
:end
@exit
@echo off
:loop
set /p a=确定要执行文件比较功能吗?(1继续,0退出)
if /i '%a%'=='1' goto continue
if /i '%a%'=='0' goto end
echo 输入有误,请重新输入:&&goto loop
:continue
cd D:\平台在线产品处理表
start python 文件比较优化精简版.py
:end
@exit
====================分割线,以下为转载内容======================================
@echo off
:loop
set /p a=确定要执行吗?(1继续,0退出)
if /i '%a%'=='1' goto continue
if /i '%a%'=='0' goto end
echo 输入有误,请重新输入:&&goto loop
:continue
echo 当前盘符:%~d0
echo 当前路径:%cd%
echo 当前执行命令行:%0
echo 当前bat文件路径:%~dp0
echo 当前bat文件短路径:%~sdp0
pause
:end
@exit
@
echo
off & setlocal
:loop
set
/p
answer=Do you want to
continue
(y
/n
)
echo
You chose: %answer%
if
/i
{%answer%}=={y} goto :
yes
if
/i
{%answer%}=={n} goto :no
echo
Invalid selection, try again&&goto loop
:
yes
ECHO ================ MENU ===============
ECHO -------------------------------------
ECHO 1. Selection 1
ECHO 2. Selection 2
ECHO 3. Selection 3
ECHO ==========PRESS
'0'
TO QUIT==========
ECHO.
set
input=
set
/p
input=Please
select
a number:
if
/i
'%input%'
==
'1'
goto job_1
if
/i
'%input%'
==
'2'
goto job_2
if
/i
'%input%'
==
'3'
goto job_3
if
/i
'%input%'
==
'0'
goto end
echo
wrong number, try it again&&goto :
yes
:job_1
echo
job_1
goto end
:job_2
echo
job_2
goto end
:job_3
echo
job_3
goto end
goto end
:no
:end
echo
Good-bye!
endlocal & @
echo
on