![]() |
IOBit Software
|
|
|
||||||
| Programming Place to discuss programming including HTML, Java, C++, MySQL and others. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Here is what i am trying to do...
I have all of the covers for my DVD's in a folder on the PC. In order to decided what to watch i flick through these images. I was wondering, say if i have all the dvd covers in the folder C:\DVDCOVERS Could i then write a batch file to open a random image file? I have found 1 method on-line but it requires that i rename all of the images as numbers. I don't really want to do that. Please help!! Thanks x |
| Sponsored links |
|
|
|
#2
|
||||
|
||||
|
You could have a list of them in a file (or generate one with dir) and try possibly using a variation of that method you found to find a particular file name to show by taking that line of the file?
__________________
I.think(code); I.eat(code.spaghetti); |
|
#3
|
||||
|
||||
|
Hi, you can try this:
:: --snip--- start of batch @echo off & setlocal :: start of main rem Set your path here: set "workDir=C:\DVDCOVERS" rem Read the %random%, two times is'nt a mistake! Why? Ask Bill. rem In fact at the first time %random% is nearly the same. @set /a "rdm=%random%" set /a "rdm=%random%" rem Push to your path. pushd "%workDir%" rem Count all files in your path. (dir with /b shows only the filenames) set /a "counter=0" for /f "delims=" %%i in ('dir /b ^|find "."') do call :sub1 rem This function gives a value from 1 to upper bound of files set /a "rdNum=(%rdm%*%counter%/32767)+1" rem Start a random file set /a "counter=0" for /f "delims=" %%i in ('dir /b ^|find "."') do set "fileName=%%i" &call :sub2 rem Pop back from your path. popd "%workDir%" goto :eof :: end of main :: start of sub1 :sub1 rem For each found file set counter + 1. set /a "counter+=1" goto :eof :: end of sub1 :: start of sub2 :sub2 rem 1st: count again, rem 2nd: if counted number equals random number then start the file. set /a "counter+=1" if %counter%==%rdNum% (start "" "%fileName%") goto :eof :: end of sub2 :: -snap--- end of batch Hope that helps and regards from Germany. |
![]() |
| Tags |
| batch file random |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Batch size image editing | got2run | Software | 3 | 01-24-09 12:50 |
| Program files folder being populated with inreadable image files | peterianb | Malware Removal | 3 | 09-05-08 21:38 |
| batch RAR program? | Keyser Söze | Software | 2 | 01-24-07 21:11 |
| Need batch launching program | bigbazza | Software | 6 | 06-15-06 16:29 |
| Batch File: Storing Folder Name in Variable | SimpleMan46 | Programming | 12 | 06-30-04 08:38 |