I have following code, asking for user to fill in filename:
echo Type in your filename (path + filename):
set userinp=
set /p userinp= ^>
What I would like: already 'prefill' fullpath+filename, which the user can then edit. In most cases, this would be: %cd%+filename (most common file selected)
Type in your filename (path + filename):
> D:\Download\MyFile.txt
(the string 'D:\Download\MyFile.txt' should be editable)
NB: must be achieved strictly with Windows batch commands; no use of the other languages and/or programs.
Code taken from aGerman on Dostips.com
This method is simple and have the advantage that you may use the standard command-line navigation keys, that is, besides the edition you may enter the first letters of a folder/file and browse through the existent folders/files with TAB key. You may even put
"{TAB}"
in the prefill value to automatically prefill with the first file in current directory, or"Dat{TAB}"
for the first file that start with "Dat", etc.Note that the
cscript
command, used here to execute a line of JScript code, is a standard "DOS" command provided with all Windows versions since XP on.EDIT: Include the path of first file
You may put
"%cd%\{TAB}"
in the prefill value in order to get the first file in current folder including the path; however, this method fail if the path contain any space. The new code below fix this point, although it still may fail if at any point in the path exist two folders with same name until the first space and the wanted folder is not the first one.