Drexel dragonThe Math ForumDonate to the Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Rename and recount files in a loop
Replies: 9   Last Post: Oct 9, 2013 11:33 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 30
Registered: 1/19/12
Rename and recount files in a loop
Posted: Sep 30, 2013 7:44 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply


I am trying to rename and recount a list of grabbed frames. I would like to do rename those with the exact time.
File's name is structured like yyyy-mm-gg_hh-mm-ss_framenumber.
In particular, frame number has to be between 0 and 7(here I stopped), and after that the number of seconds must to increase, and following also the minutes (after 59 minutes) and so on.

Can somebody help me, please?

close all
clear all
a ='C:\Path';
A =dir( fullfile(a, '*.bmp') );
fileNames = { A.name };

dates = char(fileNames);
dates(:,1:3) = []; %Remove first four random characters
time = dates(:,12:17); %Remove file extension
dates= datenum(datesT,'yyyy-mm-dd_HHMMSS'); %Convert date strings to matlab format

for iFile = 1 : numel( A )

[PATH,NAME,EXT] = fileparts(A(iFile).name);
yy=[NAME(4) NAME(5) NAME(6) NAME(7)];
mth=[NAME(9) NAME(10)];
gg=[NAME(12) NAME(13)];
hh=[NAME(15) NAME(16)];
mm=[NAME(17) NAME(18)];
ss=[NAME(19) NAME(20)];
frame=[NAME(22) NAME(23) NAME(24)];

for k=0:7
newName = [yy mth gg '_' hh mm ss '_' num2str(k) ,EXT];



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum 1994-2015. All Rights Reserved.