' ------------------------------------------------------------------------------------ ' SortOnCreationDate.vbs ' Sort the current album using the CreationDate of the files. ' ------------------------------------------------------------------------------------ Option Explicit app.ClearTrace Dim fso, f1,f2, alb Set fso = CreateObject("Scripting.FileSystemObject") set alb = app.GetCurrentAlbum dim s, k s = "This script will sort the current album using the creation date of the pictures" & chr(13) s = s & "Click Yes to proceed" & chr(13) s = s & "Click No to abort" k = MsgBox( s, vbYesNo, "SortOnCreationDate" ) if k = vbYes then dim i, nbPic, pic1, 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 pic1 = alb.GetPicture(i) Set pic2 = alb.GetPicture(i+1) Set f1 = fso.GetFile(alb.ExpandMacro(pic1,"%RP")) Set f2 = fso.GetFile(alb.ExpandMacro(pic2,"%RP")) if f2.DateCreated < f1.DateCreated then 'if f2.DateLastModified < f1.DateLastModified then alb.MovePicture pic2, i, False bDone = False end if set f1 = Nothing set f2 = Nothing next loop until bDone=True alb.Redraw app.Trace "Done !" end if