Picture rename: Difference between revisions
From Elch-Wiki
Jump to navigationJump to search
(Created page with "== Problem == Gewisse Digi-Cams numerieren die Bilder einfach fortlaufend, statt den Filenamen aus dem Aufnahmedatum zu bilden == Lösung == <pre>picrename.sh</pre> im Home == Script == <pre> #!/usr/bin/bash for file in *JPG do # Uncomment if the file-create/-modify date should be modified to change e.g. timezones! # touch -d "$( date -d @$(( $(stat -c '%Y' $file) - 12*60*60 )) )" $file # Take the file-create/-modify date as the new filename newfile=$(date...") |
(No difference)
|
Revision as of 08:36, 30 April 2023
Problem
Gewisse Digi-Cams numerieren die Bilder einfach fortlaufend, statt den Filenamen aus dem Aufnahmedatum zu bilden
Lösung
picrename.sh
im Home
Script
#!/usr/bin/bash for file in *JPG do # Uncomment if the file-create/-modify date should be modified to change e.g. timezones! # touch -d "$( date -d @$(( $(stat -c '%Y' $file) - 12*60*60 )) )" $file # Take the file-create/-modify date as the new filename newfile=$(date +"%Y%m%d_%H%M%S_$file" -d "$(stat -c "%y" $file)") # Rename mv "$file" "$newfile" done