HTML Tidy for Windows, Batch Files for the Command Prompt

HTML Tidy documentation, not duplicated here, explains the settings in the batch files. To mention one setting, the newline option is set to save files in the Unix / Linux format. Windows is commonly the development environment for sites hosted by Linux.

XHTML 1.0 Strict Batch Files

XHTML 1.0 Transitional Batch Files

HTML 4.01 Transitional Batch Files

Links

XHTML 1.0 Strict Batch Files

ts.bat - When run, "ts filename," runs Tidy on the file: filename.html

@echo .
@echo .
@tidy --doctype strict --output-xhtml yes --char-encoding utf8 --newline lf --clean yes --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes %1.html

tsall.bat - When run, "tsall," runs Tidy on all HTML files in the active directory and its subdirectories.

for /f "tokens=*" %%a in ('dir /b /s *.html') do tidy --doctype strict --output-xhtml yes --char-encoding utf8 --newline lf --clean yes --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes "%%a" | echo file: %%a
@echo .
@echo .
@dir *.html /o:d

XHTML 1.0 Transitional Batch Files

tt.bat - When run, "tt filename," runs Tidy on the file: filename.html

@echo .
@echo .
@tidy --doctype transitional --output-xhtml yes --char-encoding utf8 --newline lf --clean yes --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes %1.html

ttall.bat - When run, "ttall," runs Tidy on all HTML files in the active directory and its subdirectories.

for /f "tokens=*" %%a in ('dir /b /s *.html') do tidy --doctype transitional --output-xhtml yes --char-encoding utf8 --newline lf --clean yes --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes "%%a" | echo file: %%a
@echo .
@echo .
@dir *.html /o:d

HTML 4.01 Transitional Batch Files

t4.bat - When run, "t4 filename," runs Tidy on the file: filename.html

@echo .
@echo .
@tidy --doctype auto --output-html yes --char-encoding utf8 --newline lf --clean no --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes %1.html

t4all.bat - When run, "t4all," runs Tidy on all HTML files in the active directory and its subdirectories.

for /f "tokens=*" %%a in ('dir /b /s *.html') do tidy --doctype auto --output-html yes --char-encoding utf8 --newline lf --clean no --escape-cdata yes --indent auto --indent-attributes no --join-classes yes --show-errors 99 --tidy-mark no --wrap 0 --write-back yes "%%a" | echo file: %%a
@echo .
@echo .
@dir *.html /o:d

Because auto doctype is the closest thing Tidy has to specifying the HTML 4.01 doctype (outside of a config file) the t4 batch file might have to be run three times against a file for Tidy to get to HTML 4.01. The first run will make the file HTML 4.01. The second run will recognize the file as HTML 4.01 and strip the current doctype if it disagrees. The third run will add the HTML 4.01 doctype.

Links

HTML Tidy for Windows, Latest Version

Sponsor - crmOpenSourceSoftware.com

CRM open source software