1.批处理删除qq音乐自动下载的歌词文件
@echo off
echo 正在清除歌词文件,请稍等......
del /f /s /q "D:/Program Files/Tencent/QQMusic/QQMusicData/QQMusicLyric/*.lrc"
echo 清除歌词文件完成!
echo. & pause
注意:
/f 强制删除只读文件
/q 指定静音状态。不提示您确认删除。
/s 从当前目录及其所有子目录中删除指定文件。显示正在被删除的文件名。
路径要加""
2.利用环境变量判断文件是否存在
查看环境变量:以XP为例,我的电脑-右键-属性-高级-环境变量,这里可以编辑一些变量.
例子1.
@echo off
if exist "%windir%/system32/a.exe" (echo %windir%/system32/a.exe exist) else echo %windir%/system32/a.exe not exist
pause
例子2.
@echo off
if exist "%Temp%/a.exe" (echo a.exe exist) else dir %Temp%
pause
3.SET的使用
@echo on
set var="d:/Music"
if exist "%var%/知足.mp3" (start dir %var%) else echo Not exist
4.清空回收站
@echo off
echo 清空回收站
setlocal enabledelayedexpansion
for /f "delims=/" %%i in ('fsutil fsinfo drives^|find /v ""') do (
set var=%%i
set drive=!var:~-2!
fsutil fsinfo drivetype !drive!|find "固定">nul && (
if exist !drive!/RECYCLER rd/s/q !drive!/RECYCLER >nul 2>nul
if exist !drive!/Recycled rd/s/q !drive!/Recycled >nul 2>nul
)
)
fsutil的解释,>nul 2>nul的解释 ,setlocal的解释
5.清除系统垃圾
@echo off
echo 正在清除系统垃圾文件,请稍等......
del /f /s /q %systemdrive%/*.tmp
del /f /s /q %systemdrive%/*._mp
del /f /s /q %systemdrive%/*.log
del /f /s /q %systemdrive%/*.gid
del /f /s /q %systemdrive%/*.chk
del /f /s /q %systemdrive%/*.old
del /f /s /q %systemdrive%/recycled/*.*
del /f /s /q %windir%/*.bak
del /f /s /q %windir%/prefetch/*.*
rd /s /q %windir%/temp & md %windir%/temp
del /f /q %userprofile%/cookies/*.*
del /f /q %userprofile%/recent/*.*
del /f /s /q "%userprofile%/Local Settings/Temporary Internet Files/*.*"
del /f /s /q "%userprofile%/Local Settings/Temp/*.*"
del /f /s /q "%userprofile%/recent/*.*"
del /f /s /q "D:/FavoriteVideo/*.*"
echo 清除系统LJ完成!
echo. & pause