I am working on an elaborate script for Windows using CMD.EXE scripting.

It walks a tree of files and folders and uses our specialized file transfer program to send the tree to a remote location. Successfully transmitted files (and empty folders) are moved to a SENT folder leaving behind only this that did not get transmitted in this pass.

In case you are wondering, it is a customer requirement to do it this way. This is actually a replacement for a Python version that is completely unacceptable for certification in this environment (military).

This has grown to a set of twenty *.cmd files and includes both CALL to other scripts and CALL to :LABEL "subroutines".

I am mostly editing this with Emacs (on Windows) and got to wondering if I could generate a usable TAGS table.

Meta-. navigation would be nice but so would Meta-x tags-query-replace

Has anyone generated a TAGS table for this sort of thing?

  • 1
    I've been an Emacs user since first using it on a... wait for it... Symbolics Lisp Machine in 1984 - really!
    – lcbrevard
    Commented Jan 16, 2020 at 19:00

1 Answer 1


That's definitely doable. I use Emacs lisp to append content into TAGS (https://blog.binchen.org/posts/javascript-code-navigation-in-counsel-etags.html)

Create a simple hello.c with below content,

int hello() {

int bye() {

Use ctags to create TAGS. So run ctags -e hello.c in shell (see https://www.emacswiki.org/emacs/BuildTags if you prefer etags. I don't like etags. It's not actively maintained and has leass features than ctags).

A file named TAGS is created, here is its content displayed in Emacs,

enter image description here

hello.c is file name. the number after file name is file size. ^? is one character whose ASCII code is 127. ^A is one character whose code is 1. After ^A is line-numer,char-position-in-file.

PowerShell script supports file IO and string (see https://docs.microsoft.com/en-us/powershell/scripting/samples/sample-scripts-for-administration?view=powershell-7) so you can use it to create TAGS. You can use any other programming language to create TAGS if and only if that language supports file IO and string manipulation.

If ctags is not restricted by your organization, you can customize the regular expression of ctags to parse the dos batch file,

Run ctags -e --regex-DosBatch="/^:LABEL \"([a-zA-Z0-9]*)\"/\1/f/" hello.cmd in shell

hello.cmd is like,

IF %1==12 GOTO specialcase
   rem sub1
   Echo the input was NOT 12

:LABEL "sub1"
   Echo the input was  12

If you run the ctags without file name, it will scan the whole directory recursively.

DosBatch is the name of the language which ctags supports by default. Run ctags --list-maps to list all languages.

  • Thanks, but I've been using TAGS files for Emacs Lisp, C, and C++ for quite awhile. I just wondered if anyone had already worked out a script to create a usable TAGS file for a project that was all CMD.EXE scripts. A related issue (but not what I need currently) would be to generate TAGS for a project consisting of multiple PowerShell scripts.
    – lcbrevard
    Commented Jan 17, 2020 at 16:12
  • @lcbrevard , you could write your own script to generate TAGS or use ctags to create TAGS.
    – chen bin
    Commented Jan 18, 2020 at 6:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.