' ------------------------------------------------------------------------------------ ' AssignPictureToAlbum.vbs ' This script is for sorting pictures stored in an album by moving picture to one ' album in a set of target albums. ' Assign the script to Ctrl key + 0-9 keys on the numerical keypad. ' Pressing one of these shortcuts will move the current picture to the corresponding ' target album and will also move the picture file to the album folder. ' ------------------------------------------------------------------------------------ Option Explicit ' Key codes for the 0-9 keys on the numerical keypad const VK_NUMPAD0 = &h60 const VK_NUMPAD9 = &h69 const bMovePictureToAlbumFolder = True dim tabAlbum(10), alb, pic, k, alb2, sPicFileName, fso ' List of target albums tabAlbum(0) = "C:\Documents and Settings\vz\Mes documents\Album_A.alb" tabAlbum(1) = "C:\Documents and Settings\vz\Mes documents\Album_B.alb" tabAlbum(2) = "C:\Documents and Settings\vz\Mes documents\Album_C.alb" tabAlbum(3) = "C:\Documents and Settings\vz\Mes documents\Album_D.alb" tabAlbum(4) = "C:\Documents and Settings\vz\Mes documents\Album_E.alb" tabAlbum(5) = "C:\Documents and Settings\vz\Mes documents\Album_F.alb" tabAlbum(6) = "C:\Documents and Settings\vz\Mes documents\Album_G.alb" tabAlbum(7) = "C:\Documents and Settings\vz\Mes documents\Album_H.alb" tabAlbum(8) = "C:\Documents and Settings\vz\Mes documents\Album_I.alb" tabAlbum(9) = "C:\Documents and Settings\vz\Mes documents\Album_J.alb" app.ClearTrace Set fso = CreateObject("Scripting.FileSystemObject") 'app.lLastKeyPressed = VK_NUMPAD0 set alb = app.GetCurrentAlbum set pic = alb.GetVisiblePicture( alb.nCurrentPicture ) sPicFileName = "" ' Don't allow the script to run in full-screen mode as it erase the currently displayed picture if not pic is Nothing and app.GetFullScreenView is Nothing then k = (app.lLastKeyPressed and &hff) if (k >= VK_NUMPAD0 and k <= VK_NUMPAD9) then ' Get the number of the target album k = k - VK_NUMPAD0 ' Retrieve target album and loaded if needed set alb2 = app.LoadAlbum( tabAlbum( k ) ) if not alb2 is Nothing then sPicFileName = alb.ExpandMacro( Pic, "%RP" ) alb2.AddPicture( sPicFileName ) 'app.Trace sPicFileName ' Move picture file too ? if bMovePictureToAlbumFolder then dim file, sAlbumFolder, i, sNewFileName, pic2 sAlbumFolder = alb2.ExpandMacro( Nothing, "%Af" ) sNewFileName = sAlbumFolder & "\" & pic.sShortFileName 'app.Trace sNewFileName Set file = fso.GetFile( sPicFileName ) file.Move sNewFileName ' Adjust the file name in the target album set pic2 = alb2.GetPicture( alb2.nbPicture-1 ) pic2.sFileName = sNewFileName end if ' Go back to the sorting album and remove the picture friom it alb.Activate alb.DeletePicture pic ' Select the new current picture set pic = alb.GetVisiblePicture( alb.nCurrentPicture ) pic.bSelected = True alb.ReDraw else MsgBox "Cannot load album '" & tabAlbum(k) end if end if end if if sPicFileName <> "" then app.StatusBarText "Picture '" & sPicFileName & "' moved to album '" & tabAlbum(k)