rename_files_by_age

Automatically rename files by age from a set date. I use it to date pictures and videos of my kid.
349 Downloads
Updated 12 Aug 2013

View License

% function rename_files_by_age()
%
% function to automatically rename pictures and videos to start with age
% from specified date. Written for baby pictures.
% Example: Changes name from 'foo' to '##Y##M##D_foo'
% ie - 'foo.jpg' to '01Y03M10D_foo.jpg' if pic taken 1 year, 3 months, 10
% days after birth
%
% I tried to keep it simple, so I just copy it into a folder with files I
% want to rename and then run it
% I put all video files in a subfolder called 'videos'
% change variable folder_videos below if you do something different
%
% my files came from many different sources
% (iPhone, android phone, multiple cameras, ipcamera)
% and they don't all have the same info, so here's what I came up with
% for *.jpg pictures:
% - I try exifread to get DateTimeOriginal
% - if that doesn't work, I use imfinfo to get FileModDate
% for videos:
% 1. *.3gp files from android phone
% -named as VID_YYYYMMDD_HHMMSS.3gp
% -just use the date from the original filename
% 2. *.mp4 files from android phone
% -named as YYYYMMDD_HHMMSS.mp4
% -I use picasa, which doesn't like mp4 files, so I rename as .mov
% -then just use the date from the original filename
% 3. *.avi files from digital camera
% - not ideal b/c only have access to last change date, not date created...
% would be a problem if only upload videos from camera rarely
% 4. *.mov files from iphone
% - not ideal b/c only have access to last change date, not date created...
% would be a problem if only upload videos from iphone rarely
% 5. *.wmv files from webcam
% - not ideal b/c only have access to last change date, not date created...
%
% v1 - Nathan Tomlin. Feb 12, 2012. nathan.a.tomlin@gmail.com
% v2 - Feb 28, 2012. Fixed error in .jpg renaming and added .wmv check
% v3 - Aug 11, 2013. Fixed error in age rename and added .mp4 check

Cite As

Nathan Tomlin (2024). rename_files_by_age (https://www.mathworks.com/matlabcentral/fileexchange/35052-rename_files_by_age), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2007a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Just for fun in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

fixed an error and added mp4 video check.

1.1.0.0

Feb 28, 2012. Fixed error in .jpg renaming and added .wmv check

1.0.0.0