Skip to content

Commit

Permalink
feat: get the creation date from original, set to converted
Browse files Browse the repository at this point in the history
  • Loading branch information
renoirb committed Jun 4, 2022
1 parent 0d7cb46 commit 6d4e4e7
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions heic2jpg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@

src=$1
size=$(find $src -type f | grep -i '\.heic$' | wc -l)
cnt=0
iter=0

for i in $(find $src -type f | grep -i '\.heic$')
do
((cnt=cnt+1))
iter=$((iter+1))
target=$(echo $i | sed 's/heic$/jpg/i')
printf "$i convert to $target\n"
# https://www.tutorialkart.com/bash-shell-scripting/bash-date-format-options-examples/
FILE_DATE=$(/bin/date +%Y%m%d%H%M.%S -r ${target})
printf "$iter/$size:\n"
printf " File: $i\n"
printf " Creation date: $FILE_DATE\n"
printf " Convert as file: $target\n"
/usr/bin/convert $i $target
printf " [$cnt/$size]\r"
# Set the same date as the original image
/bin/touch -a -m -t $FILE_DATE $target
printf "\n\r"
done

printf "\n=== Finished ===\n"

0 comments on commit 6d4e4e7

Please sign in to comment.