I would like to run HTML Tidy (aka tidy-html5) recursively on all the html files including those in the sub-directories. While tidy -mq ./src/*.html
works on all html files in the src directory, it does not run on sub-directories.
My HTML directory structure looks like this, and each directory contains multiple html files:
└── src/
├── 2017-12-01-post1/*.html
├── 2017-12-15-post2/*.html
├── 2018-01-03-post3/*.html
├── 2018-04-01-post4/*.html
└── ... (more dir)
Is it possible to do something like tidy -mq ./src/**/*.html
? (Similar to how Prettier works)
I settled on using find
command (Linux, Mac, *nix, BSD) like this :
find . -name '*.html' -type f -print -exec tidy -mq '{}' \;
This will search through the directories recursively for all HTML files and execute tidy
on them.
Alternatively, in Bash, use shopt -s globstar
:
shopt -s globstar
tidy -mq **/*.html
In ZSH, it just works without any other setting:
tidy -mq **/*.html