Skip to content

Instantly share code, notes, and snippets.

@jadedgnome
Forked from ohhdemgirls/rename.sh
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jadedgnome/436adf1f1f4ae41823a6 to your computer and use it in GitHub Desktop.
Save jadedgnome/436adf1f1f4ae41823a6 to your computer and use it in GitHub Desktop.
#!/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