How do I get Google Drive to open text files with arbitrary extensions as text files?

If you just want to view the files you can do the following:

  1. Save the file with a .txt extension, i.e. filename.bat becomes filename.bat.txt
  2. Add it to google drive
  3. Remove the .txt extension, filename.bat.txt goes back to filename.bat

Google determines the context type based on the extension and retains that through future file renamings, so you'll be able to view it even after changing back to the original extension.