@echo off setlocal enabledelayedexpansion REM 提示用户输入文件夹路径 set /p "folder_path=请输入文件夹路径: " REM 检查输入的文件夹路径是否存在 ifnotexist "%folder_path%" ( echo 错误:文件夹路径不存在。 pause exit /b ) REM 获取文件夹中的所有文件并按最后更新时间排序 for /f "tokens=*" %%Fin ('dir /b /o:-d "%folder_path%\*"') do ( REM 获取文件的扩展名 set "file_ext=%%~xF" REM 构造新的文件名 set /a "file_index+=1" set "new_file_name=!file_index!!file_ext!" REM 构造文件的完整路径 set "old_file_path=%folder_path%\%%F" set "new_file_path=%folder_path%\!new_file_name!" REM 执行文件重命名 ren "!old_file_path!" "!new_file_name!" )
@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 %windir%\*.bak del /f /q %userprofile%\recent\*.* del /f /s /q "%userprofile%\Local Settings\TemporaryInternet Files\*.*" del /f /s /q "%userprofile%\LocalSettings\Temp\*.*" del /f /s /q "%userprofile%\recent\*.*" echo 清除系统LJ完成! echo. & pause
@echo off :: Check for permissions >nul2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
:: Store the original parameters set "params=%*"
:: If error flag set, we donot have admin. if '%errorlevel%' NEQ '0' ( echo Administrator privileges are required to modify system PATH echo Requesting administrative privileges... goto UACPrompt ) else ( goto gotAdmin )
:gotAdmin ifexist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" ) pushd "%CD%" CD /D "%~dp0"
setlocal
:: Check if a file path was provided by drag-and-drop if "%~1" == "" ( :: No file was dragged. Ask user for a path. echo No file was dragged onto this script. set /p "filePath=Please enter a path to add to the PATH variable: " if "%filePath%"=="" ( echo Error: No path was provided. pause exit /b 1 ) ) else ( :: Check if the dragged item is a directory or file ifexist "%~1\" ( :: It's a directory, use its path directly set "filePath=%~1" ) else ( :: It's a file, use its parent directory set "filePath=%~dp1" ) )
:: Remove trailing backslash if present if "%filePath:~-1%"=="\" set "filePath=%filePath:~0,-1%"
:: Retrieve current PATH environment variable from registry for /f "tokens=2* delims= " %%ain ( 'reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v Path' ) do ( set "currentPath=%%b" )
:: Check if the new path is already inPATH echo Checking if "%filePath%" is already in the PATH... echo "%currentPath%" | find /i "%filePath%" >nul ifnoterrorlevel1 ( echoPath "%filePath%" is already in the PATH. pause exit /b 0 )
:: Add the new path to PATH echo Adding "%filePath%" to the PATH... set "newPath=%currentPath%;%filePath%"
:: Broadcast the environment change for current session setx PATH "%newPath%" /m
echoPath "%filePath%" has been successfully added to the PATH. echo Please restart your computer or any open terminal/command prompt windows for the change to take effect. pause endlocal