0

How can I see only .txt here?

screenshot of an file open dialog in Windows

The source is from https://stackoverflow.com/a/37079633/8927505

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%"
Melebius
  • 6,183
  • 4
  • 39
  • 52
oli blue
  • 25
  • 4
  • Please describe what the code is currently doing and the result you want. – lit Nov 13 '17 at 19:47
  • i have image add on top. At the point where it is yellow I just want only ".txt" – oli blue Nov 13 '17 at 20:06
  • 1
    If you mean that you want to use a file filter in the file dialog launched from the batch file, there are other solutions in that stackoverflow thread that already show how to use a file filter. If you're targetting newer windows versions that have PowerShell, then try the Powershell solution from that thread. They do have other solutions there for XP too. As for the one you copied here, seems to use an HTML file picker via the input tag. There's an "accept" attribute for that, but not all browsers support it. See https://stackoverflow.com/questions/3521122/html-input-type-file-apply-a-filter – George Birbilis Nov 14 '17 at 07:36
  • btw, .net tag should be remove from here - this is WSH (Windows Script Host) and HTA (HyperText Application) related – George Birbilis Nov 14 '17 at 07:38

0 Answers0