Thursday, May 28, 2015

Today I learned... Windows batch loop for all files

Here is a one-liner that can be used in a Windows batch script to run a command (in this case, the GraphViz dot.exe application) once for each file in a directory (with a globbed filter).

The syntax is kind of ugly, but %%f is the filename and %%~nf is the filename without the extension.

FOR %%f IN (*.gv) DO dot -Tpng ".\%%f" -o ".\%%~nf.png"

This converts all GraphViz DOT files in a directory into PNG format.

More examples and documentation here: http://academic.evergreen.edu/projects/biophysics/technotes/program/batch.htm

No comments:

Post a Comment