So I'm trying to recursively search folder, and as you might imagine it will be the "Photos"-folder in MacOS.
And in the process, I would like to change the file name, why you might ask? Because Nextcloud is for some reason changing the image name to year-month-day hour-minute-second $(increment number)
. So I need to be able to define this starting increment number.
This is what I have so far:
# Lets say that starting increment number should be I=7398
# name="$(stat -f '%Sm' -t '%y-%m-%d %H-%M-%S' "$file").$(ls "$file"|cut -d . -f2)"
# echo $name
find . -type f -iname '*.jpg' -size +500k -exec sh -c '
for file in "$@"; do
folder="/path/to/backup/folder/$(stat -f '%Sm' -t '%Y/%m' "$file")"
echo mkdir -p "$folder"
echo cp "$file" "$folder"
done
' sh {} +
This works perfect! But I would like to in the process change the name from the files EXIF data, to be '%y-%m-%d %H-%M-%S {increment number}'.ext
, 18-08-15 18-32-29 3453.JPG
or whatever it is. Is this possible?
This above script reads a JPG, creates directory of the year the file image was created, created another folder corresponding to the month, copies the file to that year folder.
Expected result: also change name '%y-%m-%d %H-%M-%S {increment number}'.ext
~/backup/2018/01
and rename it to2018-01-22 13-00-22.JPG $(increment)
. (in this example it is one file, but I have around 30k?