Last active
January 4, 2016 10:49
-
-
Save ohhdemgirls/8611495 to your computer and use it in GitHub Desktop.
Rename html files based on title tag
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Rename the ouput html file from redditPostArchiver with the reddit thread title. | |
# https://github.com/sJohnsonStoever/redditPostArchiver | |
for f in *.html; | |
do | |
title=$( awk 'BEGIN{IGNORECASE=1;FS="<title>|</title>";RS=EOF} {print $2}' "$f" ) | |
mv -i "$f" "${title//[^a-zA-Z0-9\._\- ]}_$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment