How to fix this code to choose only text files?

1

1

I am running a batch program to pick out the text files from a dialog window, but it's picking all type of files instead.

The batch file I'm running:

    set dialog="about:<input type=file id=FILE><script>FILE.click();new ActiveXObject
    set dialog=%dialog%('Scripting.FileSystemObject').GetStandardStream(1).WriteLine(FILE.value);
    set dialog=%dialog%close();resizeTo(0,0);</script>"

    for /f "tokens=* delims=" %%p in ('mshta.exe %dialog%') do set "file=%%p"
    echo selected  file is : "%file%"
    pause

Expected output:

The pop up file browser must only choose text files *.txt instead all files *.*

Philip

Posted 2019-06-28T13:54:01.517

Reputation: 596

1

maybe accept attribute mentioned at https://stackoverflow.com/questions/4328947/limit-file-format-when-using-input-type-file helps

– Florian Straub – 2019-07-03T08:55:35.377

No answers