常用处理脚本
-
时间同步
@echo off net start w32time w32tm /config /update w32tm /resync /rediscover net stop w32time
-
图标缓存清理
@echo off rem 关闭Windows外壳程序explorer taskkill /f /im explorer.exe rem 清理系统图标缓存数据库 attrib -h -s -r "%userprofile%\AppData\Local\IconCache.db" del /f "%userprofile%\AppData\Local\IconCache.db" attrib /s /d -h -s -r "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\*" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_32.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_96.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_102.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_256.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_1024.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_idx.db" del /f "%userprofile%\AppData\Local\Microsoft\Windows\Explorer\thumbcache_sr.db" rem 清理 系统托盘记忆的图标 echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v IconStreams echo y|reg delete "HKEY_CLASSES_ROOT\Local Settings\Software\Microsoft\Windows\CurrentVersion\TrayNotify" /v PastIconsStream rem 重启Windows外壳程序explorer start explorer
-
批量合并多个文件夹内的文件
@echo off
set dd=合并
md "%dd%" 2>nul
for /d %%a in (*)do if not "%%a"=="%dd%" (
echo %%a
for /r %%b in ("%%a\*")do (
echo ... %%~nxb
if exist "%dd%\%%~nxb" (
set n=1&set "f=%%b"
call :yky "%%~nb" "%%~xb"
)else copy "%%b" "%dd%\"2>nul
)
rd/s/q "%%b"
)
goto :eof
:yky
set/a n+=1
if exist "%dd%\%~1_%n%%~2" goto :yky
copy "%f%" "%dd%\%~1_%n%%~2">nul
goto :eof
应用场景:
- 匹配文本中的字符创
@echo off
set var=jupyter
for /f "skip=2" %%a in ('findstr "%var%" a.txt') do (
echo %%a >> request.txt)