-1

我需要这个作为基本程序。到目前为止,我能做的是跟踪预定义文件是否存在,但仅此而已。我正在尝试这样做:

  1. 选择一个文件
  2. 看看是否存在
  3. 找到它的路径
  4. 将路径保存在变量下,或类似的东西
  5. 向用户显示路径
  6. (执行文件,可选)

有没有办法做到这一点,脚本是什么?如果我不清楚,请告诉我。提前致谢

4

1 回答 1

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
于 2013-05-03T08:29:32.597 回答