' ------------------------------------------------------------------------------------ ' LoadListFileToAlbum.vbs ' Build an album from a text file listing the pictures to add. ' The text file must have the same format as the ones generated with the "Tools > ' Export album" command and selecting the "Simple text List" and "Standard" options. ' For instance: ' Album name = Demo album ' Album comment = This is a demo album ' Created = 2001/12/31 - 14:07:29 ' Last saved = 2002/12/17 - 16:53:23 ' Slide size = 136 ' Thumbnail size = 120 ' Number of pictures = 104 (visible = 102) ' ' Image #1 : C:\Program Files\MyAlbum\Images\04250043.jpg ' Comment of the first picture ' Comments can appear on more than one line ' Image #2 : C:\Program Files\MyAlbum\Images\04280166.jpg ' .... ' ------------------------------------------------------------------------------------ Option Explicit Const ForReading = 1, ForWriting = 2 app.ClearTrace Dim alb, fso, f, s, k, bPic, pic, sFile Set fso = CreateObject("Scripting.FileSystemObject") app.Trace "Creating a new empty album..." set alb = app.NewAlbum app.Trace "Opening the list file..." if app.Version > "2.1.1" then sFile = app.GetFilename( "Select the text file to import", 0, "", "Text file (*.txt)|*.txt|All files (*.*)|*.*||", 0) else sFile = InputBox("Type the name of the text file to import") end if if sFile <> "" then Set f = fso.OpenTextFile( sFile, ForReading) bPic = False set pic = nothing Do While f.AtEndOfStream <> True s = f.ReadLine app.Trace s if left(s,7) = "Image #" then k = instr(s,":") if k > 0 then app.Trace chr(9) & "Picture found = " & mid(s, k+2) set pic = alb.AddPicture( mid(s, k+2) ) if pic is Nothing then app.Trace "Caution: picture """ & mid(s, k+2) & """ not found" 'set pic = alb.NewPicture( 32,32,16,255) bPic = True end if else ' Process picture comment if bPic and not pic is nothing and s <> " (" then s = mid(s,3) app.Trace chr(9) & "Found comment = '" & s & "'" pic.sComment = s end if bPic = False end if Loop f.Close alb.Redraw end if app.Trace "Done !"