Replace groups of spaces or blanks by tab characters on the command line with the free Swiss File Knife for Windows, Mac OS X and Linux.

sfk entab=tabsize dir ext1 [ext2 ...]

replace groups of spaces by tabs within file(s).

   -to outmask   do not overwrite original files, but write
                 to output files according to outmask, e.g.
                 -to tmp\$path\$base.$ext or -to tmp\$file
   -yes          if files are selected, really (re)write them.
                 without -yes, entab is only simulated.
   -memlimit=n   process files with up to n mbytes (default=300).
   -nowarn       do not tell about skipped or unreadable files.

see also
   sfk scantab   list files containing TAB characters.
   sfk help opt  how to change the memlimit permanently.
   sfk view      a text file viewer that can show all TAB
                 characters in blue by pressing CTRL+T.

web reference

   sfk entab=3 sources .cpp .hpp
      replace 3 spaces each by a TAB character in all .cpp
      and .hpp files within folder sources.

   sfk entab=3 singleFileName.txt
      the same, but only in a single file.