Skip to content

Instantly share code, notes, and snippets.

@mikelittle
Last active June 26, 2022 10:25
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 mikelittle/d145809ce276bdbad42b to your computer and use it in GitHub Desktop.
Save mikelittle/d145809ce276bdbad42b to your computer and use it in GitHub Desktop.
Rename file plugin contents
#! /bin/sh
# awk script:
# set field separator to :
# strip comma from field 2
# strip quotes from field 2
# strip lead space from field 2
# strip trail space from field 2
# print field 2
for FILE in `ls *.json` ; do
NAME=`cat $FILE | grep title | awk 'BEGIN { FS= ":" } { gsub( ",", "", $2 ); \
gsub( "\"", "", $2 ); \
gsub(/^[ \t]+/,"",$2); \
gsub(/[ \t]+$/,"",$2); \
print $2 }'`
#echo $NAME;
#give a different extension or move to a diff folder to stop processing them endlessly
mv "$FILE" "$NAME.xtx"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment