Last active
July 31, 2018 23:11
-
-
Save chris-kobrzak/3313c50e7fabe89b826843666072b08d to your computer and use it in GitHub Desktop.
Bulk resize images in directories preserving modification date timestamps
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
#!/usr/bin/env bash | |
for directory in */ ; do | |
dirTimestamp="$(GetFileInfo -d "$directory")" | |
( | |
cd "$directory" | |
# In this case img files have no extensions | |
for fileName in `find . -type f -maxdepth 1 ! -name "*.*"`; do | |
fileTimestamp="$(GetFileInfo -d "$fileName")" | |
sips --resampleWidth 800 "$fileName" | |
SetFile -m "$fileTimestamp" -d "$fileTimestamp" "$fileName" | |
done | |
) | |
SetFile -m "$dirTimestamp" -d "$dirTimestamp" "$directory" | |
echo "$directory $dirTimestamp" | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment