我需要这个基本程序。到目前为止,我能做的是跟踪预定义文件是否存在,但不是更多。 我正在尝试这样做:
有没有办法做到这一点,脚本是什么? 如果我不清楚,请告诉我。 提前致谢
答案 0 :(得分:0)
@echo off
setLocal
set /p file=choose a file:
set /p option=do you want to execute the file?[y/n]
if "%option%" equ "y" set /p directory=directory where you want to execute the file:
if "%option%" equ "Y" set /p directory=directory where you want to execute the file:
if not exist "%directory%\" echo directory does not exist %% exit /b 3
if not exist %file% echo file does not exists && exit /b 1
for %%F in (%file%) do (
set file_atr=%%F
set full_path=%%~fF
)
if "%file_atr::~0,1%" equ "d" echo this is a directory && exit /b 2
echo the full path is : %full_path%
if "%option%" equ "y" (
pushd %directory%
call %full_path%
popd
)
if "%option%" equ "Y" (
pushd %directory%
call %full_path%
popd
)
endLocal