Return to Snippet

Revision: 68718
at February 15, 2015 09:42 by mabafu


Updated Code
#!/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

Revision: 68717
at February 15, 2015 09:34 by mabafu


Initial Code
#!/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
######################

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

Initial URL


Initial Description
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 after executing it! I'll not bother myself with licensing... but this piece of... software may be used as you wish, and at your own peril! I don't claim credit neither responsability over it.

Initial Title
Bash Script to Fix Android Pictures and Videos Timestamp

Initial Tags
Bash, android

Initial Language
Bash