-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwallpaper_changer.bat
29 lines (26 loc) · 1023 Bytes
/
wallpaper_changer.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
@echo off
set "imageToDelete=CachedImage_1920_1080_POS2.jpg"
set "cacheLocation=C:\Users\sasidharan.govindan\AppData\Roaming\Microsoft\Windows\Themes\CachedFiles"
set "wallpaperLocation=C:\Users\sasidharan.govindan\sasidharan_gs\useless\wallpapers"
REM Check if the image to delete exists
if exist "%cacheLocation%\%imageToDelete%" (
REM Delete the image
del "%cacheLocation%\%imageToDelete%"
)
REM Get a random image from wallpaperLocation
setlocal enabledelayedexpansion
set "randomImage="
for /f %%a in ('dir /b /a-d "%wallpaperLocation%\*" ^| find /c /v ""') do (
set /a "randNum=%%a * %random% / 32768 + 1"
)
for /f "skip=%randNum% delims=" %%a in ('dir /b /a-d "%wallpaperLocation%\*"') do (
set "randomImage=%%a"
goto :ExitLoop
)
:ExitLoop
endlocal & set "randomImage=%randomImage%"
REM Rename the selected image to match the deleted image
if defined randomImage (
copy "%wallpaperLocation%\%randomImage%" "%cacheLocation%" >NUL
ren "%cacheLocation%\%randomImage%" "%imageToDelete%"
)