此批处理文件的目标是
目前,我处于第2步,希望有人可以提供帮助。
@echo off
set DIR=%CD%
cd %DIR%
set count=0
set "choice_options="
FOR %%f in (*.DAT) DO (
(Echo "%%f" | FIND /I "MODDAT" 1>NUL) || (
REM List out menu of the files the user can select
echo %%f
)
)
REM user select which file to be renamed as MODDAT.DAT
set /p LoadFile=Select file to load...
copy "%DIR%\%LoadFile%" "%DIR%\MODDAT.DAT" /Y
exit
答案 0 :(得分:0)
以下是您根据需要使用/研究的示例:
@Echo Off
SetLocal EnableDelayedExpansion
Set "baseDir=%UserProfile%\Desktop"
Set "extFile=.DAT"
Set "dstFile=MODDAT"
For /F "Delims==" %%A In ('Set item[ 2^>Nul') Do Set "%%A="
Set "i=0"
For %%A In ("%baseDir%\*%extFile%") Do If /I Not "%%~nA"=="%dstFile%" (
Set /A i+=1 & Set "item[!i!]=%%~nxA")
If %i% Equ 0 GoTo :EOF
If %i% Equ 1 (Set "item[X]=%baseDir%\%item[1]%") Else Call :Menu
Rem Your commands using the selected file, %item[X]%, begin below.
Echo Copy /Y "%item[X]%" "%dstFile%%extFile%"
Pause
GoTo :EOF
:Menu
For /L %%A In (1,1,%i%) Do (Echo %%A. !item[%%A]!)
Set /P "item[X]=Select a file from the above list: "
If Not Defined item[%item[X]%] (ClS & GoTo Menu)
Set "item[X]=%baseDir%\!item[%item[X]%]!"
Exit /B
在%UserProfile%\Desktop
行上更改4
以匹配文件的位置。
当您对输出是希望运行的命令感到满意后,请删除{{1} },从Echo
行开始,(还有可选的14
行)结束脚本。