How to list and number text file contents in batch window and allow user
selection?
I am working on an android BAT file that will perform various functions.
One is that it will examine a folder on the phone and export its contents
to a file local on my pc. From there i want to take the file names and
display them in the batch folder and numberthem so the user can select a
file name.
the following extracts the info and saves the files to my pc..
adb shell su -c "mount -o rw,remount /system"
adb shell su -c ls /system/app > apps.txt
adb shell su -c ls /system/framework > framework.txt
I can not figure out how to list these contents with numbers in the batch
window for the user to make a selection. The following will do what i want
for files in a folder, but i want to do this for file "names" on a text
document....
@ECHO OFF
SET index=1
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%f IN (*.*) DO (
SET file!index!=%%f
ECHO !index! - %%f
SET /A index=!index!+1
)
SETLOCAL DISABLEDELAYEDEXPANSION
SET /P selection="select file by number:"
SET file%selection% >nul 2>&1
IF ERRORLEVEL 1 (
ECHO invalid number selected
EXIT /B 1
)
CALL :RESOLVE %%file%selection%%%
ECHO selected file name: %file_name%
GOTO :EOF
:RESOLVE
SET file_name=%1
GOTO :EOF
How do i perform this function on a list of names in a text file rather
than a list of files in a folder?
Thanks, Jimmie
No comments:
Post a Comment