PHPWarner Posted December 24, 2009 Share Posted December 24, 2009 Hello, I need code sample for select one of the image on selected folder. For example, there are 20 images in C:\Images folder. I need to random select one of the image on this folder. 20 images are completely example so I guess the script should count total images on the selected folder and random select. Many thanks in advice. Link to comment Share on other sites More sharing options...
PHPWarner Posted December 24, 2009 Author Share Posted December 24, 2009 (edited) Update: I did sample code for explain my problem. $PicFolder = "C:\Images" $ImagesList = _FileListToArray($PicFolder) $Img = Random(1, $ImagesList[0], 1) $iPic = $PicFolder & "\" & $Img & ".jpg" This code selecting random image on C:\Images but all image names should be 1.jpg 2.jpg 3.jpg etc... If one of the image name is DSC_01.jpg it is not selecting this image. So need more global selection code. Thanks now. Edited December 24, 2009 by PHPWarner Link to comment Share on other sites More sharing options...
Yashied Posted December 24, 2009 Share Posted December 24, 2009 It is very simple. #Include <File.au3> $FileList = _FileListToArray(@WindowsDir & '\Web\Wallpaper', '*.*', 1) If (Not @error) And ($FileList[0]) Then MsgBox(0, '', $FileList[Random(1, $FileList[0])]) Else MsgBox(0, '', 'File(s) not found!') EndIf My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
PHPWarner Posted December 24, 2009 Author Share Posted December 24, 2009 Thank you so much Yashied Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now