Skip to content

Instantly share code, notes, and snippets.

@gavinheavyside
Created May 6, 2012 11:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavinheavyside/2621887 to your computer and use it in GitHub Desktop.
Save gavinheavyside/2621887 to your computer and use it in GitHub Desktop.
strip colons from filenames in an extracted report tarball
# If you just want to rename already-unzipped files
for f in `find . -type f -name "*:*"`; do mv $f `echo $f | sed 's/\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)T\([0-9]\{2\}\)\:\([0-9]\{2\}\)\:\([0-9]\{2\}\)Z/\1\2\3\4\5\6/g'`; done
#!/bin/bash
pushd $1
unzip raw-data.zip
for f in `ls raw-data`; do
newname=`echo -n $f | sed 's/\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\)T\([0-9]\{2\}\)\:\([0-9]\{2\}\)\:\([0-9]\{2\}\)Z/\1\2\3\4\5\6/g'`
mv raw-data/$f raw-data/$newname
done
rm raw-data.zip
7z a -r raw-data.zip raw-data
rm -r raw-data
unzip google-earth.zip
for f in `ls google-earth`; do
newname=`echo -n $f | sed 's/\://g'`
mv google-earth/$f google-earth/$newname
done
rm google-earth.zip
7z a -r google-earth.zip google-earth
rm -r google-earth
popd
# from the top level of an extracted report tarball
$ find . -type d -depth 1 | xargs -I {} ./filename_fixer.sh {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment