JSI Tip 4731. How do I open multiple files that match a search string in notepad?


I have scripted Multipad.bat to open from one to n instances of notepad based on a standard search string.

The syntax for using multipad.bat is:

multipad <Search String>

Examples:

multipad abc*.txt Opens all .txt file in the current directory that start with abc.
multipad *.txt Opens all .txt file in the current directory
multipad <drive:>\folder\xyz?abc.*     Opens all files in the <drive:>\folder directory that have xyz as the first 3 characters,
anything for the fourth character, abc for the 5th, 6th, and 7th character, with any extension.

Multipad.bat contains:

@echo off
setlocal
if \{%1\}==\{\} goto syntax
set file=%1
set dp=%~dp1
pushd %dp%
for /f "Tokens=*" %%i in ('DIR %file% /b /a-d') do call :openit "%%i"
popd
endlocal
goto :EOF
:syntax 
@echo multipad searchstring
endlocal
goto :EOF
:openit
start notepad.exe %1


Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish