Created
August 3, 2018 16:44
-
-
Save catichenor/f53ab49a53616ec5412ef8d3cf430742 to your computer and use it in GitHub Desktop.
Get the modification date of files inside zip archives in the current directory
This file contains hidden or 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 | |
for f in `find -maxdepth 1 . -type f -name '*.zip'`; do | |
datetime=`date -j -f "%y-%b-%d %H:%M" "$(zipinfo $f | head -n 3 | tail -n 1 | awk '{print $7 " " $8}')" +"%Y%m%d%H%M"`; | |
echo "$f $datetime" | |
# To rename, appending the date instead: mv $i `echo "$i" | sed -e "s/\(.*\)\(\..*\)/\1_${datetime}\2/"`; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note that I'm using BSD
date
, not GNUdate
to parse the date that's output fromzipinfo
.