/ Published in: Bash
After copying pictures and videos from my tablet to my PC I noticed that the original timestamp was overriden by the current date.
Fortunatelly the timestamp was still preserved in the files name.
Ex: IMG\_20150214\_202445.jpg or VID\_20140116\_091015.3gp
The script must be executed in the image's folder and voilá the original timestamp will be restored.
Please make a backup before executing it!
I'll not bother myself with licensing. This piece of... software... may be used as you wish, and also at your own peril! I don't claim credit neither responsability over it.
Fortunatelly the timestamp was still preserved in the files name.
Ex: IMG\_20150214\_202445.jpg or VID\_20140116\_091015.3gp
The script must be executed in the image's folder and voilá the original timestamp will be restored.
Please make a backup before executing it!
I'll not bother myself with licensing. This piece of... software... may be used as you wish, and also at your own peril! I don't claim credit neither responsability over it.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/bin/bash #Bash Script to Fix Android Pictures and Videos Timestamp ################################## #Works for files named under this format: AAAAYYYYMMDD_HHMMSS.EXT #Where: #A = any character #YYYYMMDD = year month day #HHMMSS = hour minute second #.EXT = any 3 character extension preceeded by a period # # It must be executed from the pictures/videos folder ###################### clear FILES="$( ls )" for file in $FILES do YEAR="${file:4:4}" MONTH="${file:8:2}" DAY="${file:10:2}" HOUR="${file:13:2}" MINUTE="${file:15:2}" SECOND="${file:17:2}" touch -a -m -t $YEAR$MONTH$DAY$HOUR$MINUTE.$SECOND $file echo $DAY/$MONTH/$YEAR $HOUR:$MINUTE:$SECOND -\> $file done