After searching around, xcopy
seemed to be the most solid choice.
set "key="
for /f "delims=" %%A in ('xcopy /w "%comspec%" "%comspec%" 2^>nul') do if not defined key set "key=%%A"
set "key=!key:~-1!"
fetches a key, with wich you can build the input.
if "!input:~-%length%!" == "!input!"
allows for checks on length (in your case 28).
You can also the input.bat
script I wrote. By using a macro you can fetch the output of the script. First you declare the macro:
set input=^
for %%. in (1 2) do if %%.==2 (^
for /F "delims=" %%I in ('input.bat !args!') do ^
set "result=%%I"^
) else set args=
then you use it like this:
setlocal EnableDelayedExpansion
%input% "prompt=Password: " "length=28"
You can then use the result
variable to get your input.
IMPORTANT
For defining the macro delayed expansion needs to be DISABLED.
While using it however, delayed expansion needs to be ENABLED.
Resources
xcopy input - DosTips.com
batch macros - DosTips.com
set input=%input:~0,28%
set input=%input:~0,28%
to parse it and only keep the first 28 characters of the file name that way. Read about it more here: dostips.com/DtTipsStringManipulation.php