You are not logged in.
Pages: 1
I want to rename pic file of my son. New filename indicates old day(month/year) of him at taken date.
Ex: His birthday: 12.02.2008
Take date: 11.05.2008
Newfilename: 02month19day.jpg
Help me please!
Offline
Hi teppi_04, welcome and congratulatory to become an daddy
I want to rename pic file of my son.
New filename indicates old day(month/year) of him at taken date.Ex: His birthday: 12.02.2008
Take date: 11.05.2008
Newfilename: 02month19day.jpg
Where comes the '19' from ?
Please provide 8 original file names and the names you want to get as pairs, so we can help you. For example:
Original name - New name
xyz.jpg - 0212.jpg
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
New filename indicates old day(month/year) of him at taken date.
His birthday: 2008-02-12
Original name - New name
2008-02-25.jpg - 0Year-0Month-13day.jpg
2008-03-15.JPG - 0Year-1Month-3day.jpg
2008-03-15.JPG - 0Year-1Month-3day.jpg
2008-03-16.JPG - 0Year-1Month-4day.jpg
2008-05-13.JPG - 0Year-3Month-1day.jpg
2008-05-25.JPG - 0Year-3Month-13day.jpg
2008-06-05.jpg - 0Year-3Month-24day.jpg
2008-09-06.JPG - 0Year-6Month-25day.jpg
Thanks so much
Offline
Ahh, now i understand
Original name - His birthday - New name
2008-02-25.jpg minus 2008-02-12 = 0Year-0Month-13day.jpg
That can be done with an script.
But that's not that easy because you have to take care of all those rules ( day of months, leap year,...)
ReNamer can use Pascal Script to rename files and can use external tool too. f.ex.: http://www.den4b.com/forum/viewtopic.php?id=536
But you can also use ReNamer to export the file name -> use any script language you like -> and re-import the new names.
Now all you need is someone who can provide you such an script... or do you code on your own?
Read the *WIKI* for HELP + MANUAL + Tips&Tricks.
If ReNamer had helped you, please *DONATE* to Denis or buy a PRO license. (Read *Lite vs Pro*)
Offline
Ok, this is the best I could come up with...
{ Date Difference Script v1 by Andrew }
var dtarr: TStringsArray;
var bday,filedt: TDateTime;
var filey,filem,filed,diffy,diffm,diffd: Word;
begin
bday := EncodeDate(2008, 2, 12);
dtarr := WideSplitString(WideExtractBaseName(FileName), '-');
filey := StrToInt(dtarr[0]);
filem := StrToInt(dtarr[1]);
filed := StrToInt(dtarr[2]);
filedt := EncodeDate(filey, filem, filed);
if (bday > filedt) then Exit;
DecodeDate(filedt-bday+1, diffy, diffm, diffd);
diffy := diffy - 1900;
diffm := diffm - 1;
FileName := IntToStr(diffy)+'Year-'+IntToStr(diffm)+'Month-'+IntToStr(diffd)+'Day'+WideExtractFileExt(FileName);
end.
Unfortunately, the output doesn't completely match what teppi_04 specified above.
2008-02-25.jpg 0Year-0Month-13Day.jpg
2008-03-15.jpg 0Year-1Month-1Day.jpg
2008-03-16.jpg 0Year-1Month-2Day.jpg
2008-05-13.jpg 0Year-3Month-1Day.jpg
2008-05-25.jpg 0Year-3Month-13Day.jpg
2008-06-05.jpg 0Year-3Month-24Day.jpg
2008-09-06.jpg 0Year-6Month-26Day.jpg
I think this is because sutracting two TDateTime variables in PascalScript doesn't take into account the number of days in the intervening months, leap years (Feb.) etc. If that had been implemented properly like in other languages, things would have been so simple... Maybe Denis can help?
So teppi_04, the thing is, either you find this enough for your needs, or else someone has to sit and write a whole new datediff() function, with days per month arrays, code for finding leap years etc. Not impossible certainly, but will take some time. It might even be far simpler to write a renaming program only for this specific case in some other language that can properly carry out date arithmetic!
Edit: Yes! Woohoo! This is nice logic if I do say so myself!
{ Date Difference Script v2 by Andrew }
var dtarr: TStringsArray;
var bday,filedt: TDateTime;
var filey,filem,filed,diffy,diffm,diffd: Word;
begin
bday := EncodeDate(2008, 2, 12);
dtarr := WideSplitString(WideExtractBaseName(FileName), '-');
filey := StrToInt(dtarr[0]);
filem := StrToInt(dtarr[1]);
filed := StrToInt(dtarr[2]);
filedt := EncodeDate(filey, filem, filed);
if (bday > filedt) then Exit;
diffy := 0; diffm := 0; diffd := 0;
while (true) do
begin
if (IncYear(bday, 1) <= filedt) then
begin
bday := IncYear(bday, 1);
diffy := diffy + 1;
end
else if (IncMonth(bday, 1) <= filedt) then
begin
bday := IncMonth(bday, 1);
diffm := diffm + 1;
end
else if (IncDay(bday, 1) <= filedt) then
begin
bday := IncDay(bday, 1);
diffd := diffd + 1;
end
else
break;
end;
FileName := IntToStr(diffy)+'Year-'+IntToStr(diffm)+'Month-'+IntToStr(diffd)+'Day'+WideExtractFileExt(FileName);
end.
P.S. For both scripts, the filenames should always be in the format - yyyy-mm-dd.jpg
Last edited by Andrew (2009-01-10 12:36)
Offline
Pages: 1