Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Associate file by name rather than extension?

Oct
364
17
Is it possible in Windows 7 to associate a file with a program based on the file name not the extension?

We download a variety of files that have standard names but all have a .TXT extension. I need to open them in Excel and that means right-click, select Open With ..., select Excel 2016. Obviously I don't want to open EVERY .txt file in Excel. The association would need to be for something like DAILY_PMT_ccyymmdd.TXT
 
Short answer: no

Long answer: Create a script that does the magic parsing. Associate .TXT files with a new ftype and invoke that ftype by running TCC and your script and pass in the file name. Then have the script invoke either the current TXT file handler or Excel.

This is untested:
Code:
ftype dailypmt="C:\TC22\TCC.EXE" /c C:\TC22\dailypmt.btm "%1"
assoc .txt=dailypmt

dailypmt.btm:
iff %# == 0 then
  echo usage: dailypmt txtfile
  quit
endiff
iff %@regex["DAILY_PMT_.+\.TXT",%1] == 1 then
  start /pgm excel %1
else
  set txtfile=%@execstr[ftype txtfile]
  start /pgm %txtfile
endiff
 

Similar threads

Back
Top