' ------------------------------------------------------------------------------------ ' SortOnCFDate.vbs ' Sort the current album ' The Date & Time Custom Fields are used to sort pictures ' ------------------------------------------------------------------------------------ Option Explicit app.ClearTrace dim alb, sCF1, sCF2 set alb = app.GetCurrentAlbum sCF1 = "Date" sCF2 = "Time" dim s, k s = "This script will sort the current album using the custom fields '" s = s & sCF1 & "' and '" & sCF2 & "'" & chr(13) s = s & "This album will be used: " & alb.sAlbumTitle & " (" & alb.FullName & ")" & chr(13) s = s & "Click Yes to proceed" & chr(13) s = s & "Click No to abort" k = MsgBox( s, vbYesNo, "SortOnCF" ) if k = vbYes then dim i, nbPic, pic, pic2, bDone, d1, d2 nbPic = alb.nbPicture app.Trace "Pictures to process: " & nbPic ' Very simple sort using two loops do bDone = True for i = 0 to nbPic-2 Set pic = alb.GetPicture(i) Set pic2 = alb.GetPicture(i+1) d1 = pic.GetCustomFieldDate(sCF1) d2 = pic2.GetCustomFieldDate(sCF1) 'app.Trace d1 & " " & d2 if d2 < d1 then alb.MovePicture pic2, i, False bDone = False else if (d2 = d1) and (pic2.GetCustomFieldDate(sCF2) < pic.GetCustomFieldDate(sCF2)) then alb.MovePicture pic2, i, False bDone = False end if end if next loop until bDone=True alb.Redraw app.Trace "Done !" end if