Scattered Scripts
This page collates all those scripts that are so short and simple that standalone page creation is not desirable.
cln
The classical three-line clean-up commands.
@echo off
cmd /c cleanmgr /sageset:65535 & cleanmgr /sagerun:65535
dism /online /Cleanup-Image /StartComponentCleanup /ResetBase
vssadmin delete shadows /all /quiet
adc
Additional clean-up—some personally added deletions that may be subject to arbitrary addendum and/or revision at my pleasure.
@echo off
chcp 65001 >nul
setlocal enableextensions
set "m="
set "n="
del /q "%AppData%\foobar2000-v2\playlists-v2.0\*.*"
del /q "%AppData%\foobar2000-v2\playlists-v2.0\*"
del /q "%AppData%\PotPlayerMini64\Playlist\*.*"
del /q "%AppData%\PotPlayerMini64\Playlist\*"
del /q "%AppData%\Daum\PotPlayer\Log\*.*"
del /q "%AppData%\Daum\PotPlayer\Log\*"
del /q "%AppData%\qbit_plugins_data\*.*"
del /q "%AppData%\qbit_plugins_data\*"
del /q "%AppData%\qBittorrent\qbit_plugins_data\*.*"
del /q "%AppData%\qBittorrent\qbit_plugins_data\*"
del /q "%AppData%\Signal\update-cache\*.*"
del /q "%AppData%\Signal\update-cache\*"
del /q "%AppData%\BaiduPCS-Go\pcs_command_history.txt"
rd /s/q "%AppData%\browsh"
rd /s/q "%AppData%\Floorp"
rd /s/q "%AppData%\gallery-dl"
rd /s/q "%AppData%\High-Logic"
rd /s/q "%AppData%\Mozilla\Firefox\Crash Reports"
rd /s/q "%AppData%\Mozilla\Firefox\Background Tasks Profiles"
rd /s/q "%AppData%\Mozilla\Firefox\Profile Groups"
rd /s/q "%AppData%\PotPlayerMini64"
rd /s/q "%AppData%\PotPlayerMini64 - Copy"
rd /s/q "%AppData%\PotPlayerMini64_original"
rd /s/q "%AppData%\SolidDocuments"
del /q "%LocalAppData%\Comms\UnistoreDB\*.*"
del /q "%LocalAppData%\Comms\UnistoreDB\*"
del /q "%LocalAppData%\mpv\cache\*.*"
del /q "%LocalAppData%\mpv\cache\*"
rd /s/q "%LocalAppData%\deno"
rd /s/q "%LocalAppData%\Floorp"
rd /s/q "%LocalAppData%\HomeDev"
rd /s/q "%LocalAppData%\Topaz Labs LLC"
rd /s/q "%LocalAppData%\Microsoft\EdgeWebView"
rd /s/q "%LocalAppData%\NEO"
rd /s/q "%LocalAppData%\OO Software"
rd /s/q "%LocalAppData%\pip\cache"
rd /s/q "%LocalAppData%\sigil-ebook\sigil\cache"
rd /s/q "%UserProfile%\AppData\LocalLow\Google\GoogleEarth"
del /q "%LocalAppData%\sigil-ebook\sigil\cache\QtWebEngine\Preview\Cache\Cache_Data\*.*"
del /q "%LocalAppData%\sigil-ebook\sigil\cache\QtWebEngine\Preview\Cache\Cache_Data\*"
del /q "%LocalAppData%\qBittorrent\logs\*.*"
del /q "%LocalAppData%\qBittorrent\logs\*"
rd /s/q "%UserProfile%\Tracing"
rd /s/q "%UserProfile%\.cache"
rd /s/q "%ProgramData%\Microsoft\EdgeUpdate"
for /f %%m in ('dir /b/s "%ProgramData%\Mozilla-*"') do set "m=%%m"
if defined m rd /s/q "%m%"
for /f %%n in ('dir /b/s "%ProgramData%\Noraneko-*"') do set "n=%%n"
if defined m rd /s/q "%n%"
rd /s/q "D:\_Hidden\TopazRes\crashpad"
rd /s/q "D:\_Hidden\TopazRes\Logs"
rd /s/q "D:\_Hidden\TopazRes\Sample Images"
findstr /virc:"^ <Find name=.*/>$" "%AppData%\Notepad++\config.xml">"%AppData%\Notepad++\config1.xml"
findstr /virc:"^ <Replace name=.*/>$" "%AppData%\Notepad++\config1.xml">"%AppData%\Notepad++\config2.xml"
findstr /virc:"^ <File filename=.*/>$" "%AppData%\Notepad++\config2.xml">"%AppData%\Notepad++\config3.xml"
del "%AppData%\Notepad++\config.xml" "%AppData%\Notepad++\config1.xml" "%AppData%\Notepad++\config2.xml"
ren "%AppData%\Notepad++\config3.xml" config.xml
endlocal
def
Delete empty folders in the current directory. It can handle up to ten levels of nested empty folders at a time—which should be more than sufficient for general uses, and you can always re-run it if ten is still not enough.
@echo off
chcp 65001 >nul
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
for /r . /d %%F in (.) do dir /b /a "%%F" | findstr "^" >nul || rd /s /q "%%F"
fpk
Firefox personal data (cookies, history, bookmarks, logins, etc) packing up script. Pass -p or -pXXX to set (or let 7-zip prompt to set) a password. If no name for the archive is designated, then filenames like FxPD_260419-2007.7z will be used. Similar bash scripts for Linux uses can be found here.
@echo off
chcp 65001 >nul
setlocal
set "a="
set "p="
set "n="
:a
if /i "%~1"=="" goto p
set "a=%~1"
if /i "%a:~0,2%"=="-p" (
set "p= %a%"
) else (
set "n=%a%"
)
shift
goto a
:p
if defined n (
if /i "%n:~-3%"==".7z" (
set "n=%n:~0,-3%"
)
)
for /f "tokens=1-6 delims=/: " %%a in ('robocopy "|" . /njh ^| find ":"') do set "a=%%a" & set "b=%%b" & set "c=%%c" & set "d=%%d" & set "e=%%e" & set "dt=!a:~2,2!!b!!c!-!d!!e!"
del /q fxpdl.txt
echo content-prefs.sqlite>>fxpdl.txt
echo cookies.sqlite>>fxpdl.txt
echo favicons.sqlite>>fxpdl.txt
echo formhistory.sqlite>>fxpdl.txt
echo key4.db>>fxpdl.txt
echo logins.json>>fxpdl.txt
echo permissions.sqlite>>fxpdl.txt
echo places.sqlite>>fxpdl.txt
if not defined n (
7z a -t7z -mx=9 -aoa -mfb=273 -md=1024m -ms=on -mqs=on -mtc -mta -mtm -stl -mhe%p% FxPD_%dt%.7z @fxpdl.txt
) else (
7z a -t7z -mx=9 -aoa -mfb=273 -md=1024m -ms=on -mqs=on -mtc -mta -mtm -stl -mhe%p% "%n%.7z" @fxpdl.txt
)
del /q fxpdl.txt
endlocal
op
Optimises PNG files. Requirement:
NB: It might take a considerably long period of time to compress larger PNG files.
chcp 65001 >nul
optipng -o7 -zm1-9 %1
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\5OP]
@="Optimise PNG"
[HKEY_CLASSES_ROOT\SystemFileAssociations\image\shell\5OP\command]
@="\"C:\\_c\\op.bat\" \"%1\""
pp
| For reasons anyone of a sound mind could not possibly understand, PotPlayer now actively blocks icon replacement via resource hacker since 1 Apr 115 AR, which renders this two-line batch obsolete. |
Prepares PotPlayer with its old icon and old skin after initial installation or updating. It requires PotPlayerOlds.7z to be extracted to C: and a working binary of Resource Hacker being renamed as rh.exe and put into %PATH%.
rh -open "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" -save "C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe" -action addoverwrite -res "C:\_c\_pp\PotPlayerMini64_100.ico" -mask ICONGROUP,100,
copy "C:\_c\_pp\Default.dsf" "C:\Program Files\DAUM\PotPlayer\Skins" /y
yr

A one-line Windows Batch script aimed at playing YouTube links in a radio style—audio only with the thumbnail picture displayed—perfect for those whose video track is irrelevant or you simply just want to listen to it without watching it to achieve some sort of serenity. It requires mpv and yt-dlp to be properly put into %PATH%.
By setting --geometry=0:1360, the mpv window will automatically locate itself at the bottom left corner of my screen, as shown in the exampled screenshot on the right. However, the number 1360 is an elusive value obtained purely through painstakingly repeated experiments and would quite possibly only work for me; adjust it beforehand or discard the geometry part altogether to let the mpv window simply be placed at the centre of the screen—after all, it will be minimised at the start anyway so it won’t be that disturbing even if its window were placed right at the centre.
| As of late December 113 AR, YouTube has changed its live stream sources to audio-video unified formats, rendering this script ineffective for live streams. Change the --geometry=0:1360 part to --geometry=0:1000 for 1080p live stream playings on screens of 4K resolution (3840 × 2160) scaling at 200%. |
@echo off
chcp 65001 >nul
start /min mpv --ytdl-format="bestaudio/best" %1 --script-opts=ytdl_hook-thumbnails=best,osc-scalewindowed=2,osc-scalefullscreen=2 --script-opts-append=osc-visibility=always --geometry=0:1360
And since YouTube has recently begun to strike at my Ad Blockers like crazy,
@echo off
chcp 65001 >nul
start mpv --ytdl-format="bv*[height<=?4200][width<=?4200]+ba/b" %1 --script-opts=osc-scalewindowed=2,osc-scalefullscreen=2