I wish this image converter tool can support command-line mode, so I could make my little tiny wallpaper changer bat file more powerful.
set ImageDir=”I:\My Documents\My Pictures\wallpaper\”
:: This might be different on each machine.
set ImageOfToday=”C:\Documents and Settings\TEMP\Local Settings\Application Data\Microsoft\Wallpaper1.bmp”
for /f %%A in (‘dir /b !ImageList!^|find /v /c “\”‘) do set C=%%A
:: %RANDOM% – expands to a random decimal number between 0 and 32767.
:: Here we only need 3 digitals, the tolal number of files won’t be greater than 999.
if !R! gtr !C! goto :loop
if !R! equ 0 goto :loop
for /f “tokens=*” %%A in (‘dir /b !ImageList!’) do (
set /a N+=1
rem Step by step to find the marked point. !R! ( !N! is adcting as an indicator.)
rem The /A switch specifies that the string to the right of the equal sign is a numerical expression that is evaluated.
if !N! equ !R! copy !ImageDir!%%A !ImageOfToday! && goto :eof
rem an extra doulbe quote seems OK here.
It works, but, what a pity I had to convert all the images to bmp format in advance!
Another drawback is, this NEW wallpaper won’t be in effect until next time login, because I don’t know how to refresh the desktop settings.
The purpose of ‘setLocal EnableDelayedExpansion‘:
if you want the variable to be expanded at execution time rather than at parse time? For that, you use “delayed expansion”, which is enabled by the
/Vcommand line option or by using the
SETLOCAL ENABLEDELAYEDEXPANSIONcommand in a batch file.
-from The old new thing.