Created
November 17, 2016 00:52
-
-
Save jerieljan/1597dea6022a373cf632903420dbfbb4 to your computer and use it in GitHub Desktop.
A simple script for processing screenshots taken with a PS3. Images are cropped (custom for me, edit it to fit your needs), files are renamed and modification dates are retained in a correct sequence.
This file contains 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 | |
# This simple script processes screenshots taken with a PS3 and does multiple things: | |
# - Crops the image to a preferred size (this depends on the game used, remove if desired, or adjust as needed.) | |
# - Renames all images by sequence, sorted by modification date (dates are copied to the new files) | |
# Prepare a file list, sorted by modification date. | |
rm FILELIST 2>/dev/null | |
ls -tdr1 *.png > FILELIST; | |
# Initialize necessary variables. | |
LIST=`cat FILELIST` | |
SEQ=1 | |
while read file; | |
do | |
# Track the current modified date | |
MDATE=`stat -c '%y' "$file"` | |
echo "$file" -> "${SEQ}.png" | |
# Then apply the desired operations and apply the modified date onto the new file. | |
# If everything works without errors, remove the old file. | |
convert "$file" -crop 1217x653+32+18 ${SEQ}.png && touch -d "${MDATE}" ${SEQ}.png && rm "$file" | |
# Proceed to the next file and count up on the sequence. | |
SEQ=$(( $SEQ + 1 )) | |
done <FILELIST | |
# Clean up the temporary file list. | |
rm FILELIST 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment