很多人在通过网盘分享文件时,会将压缩包改名或伪装为其他格式,如 .jpg .mp4 .pdf .7删z,DDDD。
解压时要手动改后缀名,一个两个还好,但多了就有点烦,专门开个重命名软件又有些重。
于是写了个脚本,在 Windows 文件右键菜单中添加「重命名为 .zip」,一键把选中文件的后缀改成 .zip。

就一个 bat 脚本,双击运行会弹出对话框:

带仓库链接好像要发推广帖?那直接贴代码吧,自己创建 文件右键菜单添加「重命名为 .zip」.bat:
@echo off
setlocal EnableExtensions
title Rename to .zip
:: ASCII-only batch. All Chinese UI/registry text is built with VBS ChrW,
:: so cmd.exe code page cannot garble it. Works on XP / Vista / 7 / 8 / 10 / 11.
:: HKCU only -- Administrator rights not required.
:: Windows 11: item is under "Show more options" / Shift+F10.
call :FIND_APPDIR
set "VBS=%APPDIR%\rename-to-zip.vbs"
set "SETUP=%TEMP%\rename-to-zip-setup.vbs"
if not exist "%APPDIR%" mkdir "%APPDIR%"
if not exist "%APPDIR%" (
echo [ERROR] Cannot create: %APPDIR%
pause
goto :EOF
)
call :WRITE_HELPER
if not exist "%VBS%" (
echo [ERROR] Cannot write helper script.
pause
goto :EOF
)
call :WRITE_SETUP
if not exist "%SETUP%" (
echo [ERROR] Cannot write setup script.
pause
goto :EOF
)
wscript.exe //nologo "%SETUP%" "%APPDIR%"
del "%SETUP%" >nul 2>&1
goto :EOF
:FIND_APPDIR
set "APPDIR="
if defined LOCALAPPDATA if exist "%LOCALAPPDATA%\" set "APPDIR=%LOCALAPPDATA%\RenameToZip"
if not defined APPDIR if exist "%USERPROFILE%\Local Settings\Application Data\" set "APPDIR=%USERPROFILE%\Local Settings\Application Data\RenameToZip"
if not defined APPDIR if exist "%USERPROFILE%\AppData\Local\" set "APPDIR=%USERPROFILE%\AppData\Local\RenameToZip"
if not defined APPDIR if exist "%APPDATA%\" set "APPDIR=%APPDATA%\RenameToZip"
if not defined APPDIR set "APPDIR=%TEMP%\RenameToZip"
goto :EOF
:WRITE_HELPER
> "%VBS%" (
echo Option Explicit
echo Dim fso, i, path, folder, base, dest, n, file
echo Set fso = CreateObject("Scripting.FileSystemObject"^)
echo For i = 0 To WScript.Arguments.Count - 1
echo path = WScript.Arguments(i^)
echo If fso.FileExists(path^) Then
echo Set file = fso.GetFile(path^)
echo folder = fso.GetParentFolderName(path^)
echo base = fso.GetBaseName(path^)
echo If Not LCase(fso.GetExtensionName(path^)^) = "zip" Then
echo dest = fso.BuildPath(folder, base ^& ".zip"^)
echo n = 2
echo Do While fso.FileExists(dest^)
echo dest = fso.BuildPath(folder, base ^& "_" ^& n ^& ".zip"^)
echo n = n + 1
echo Loop
echo On Error Resume Next
echo file.Name = fso.GetFileName(dest^)
echo If Err.Number ^<^> 0 Then
echo MsgBox "Rename failed:" ^& vbCrLf ^& path ^& vbCrLf ^& vbCrLf ^& Err.Description, 48, "Rename to .zip"
echo Err.Clear
echo End If
echo On Error GoTo 0
echo End If
echo End If
echo Next
)
goto :EOF
:WRITE_SETUP
> "%SETUP%" (
echo Option Explicit
echo Dim sh, fso, reg, appdir, helper, cmd, icon
echo Dim title, ask, okIns, okUn, choice
echo Const HKCU = ^&H80000001
echo.
echo Set sh = CreateObject("WScript.Shell"^)
echo Set fso = CreateObject("Scripting.FileSystemObject"^)
echo.
echo title = ChrW(^&H91CD^) ^& ChrW(^&H547D^) ^& ChrW(^&H540D^) ^& ChrW(^&H4E3A^) ^& " .zip"
echo.
echo ask = title ^& vbCrLf ^& vbCrLf
echo ask = ask ^& ChrW(^&H5C06^) ^& ChrW(^&H5728^) ^& ChrW(^&H6587^) ^& ChrW(^&H4EF6^)
echo ask = ask ^& ChrW(^&H53F3^) ^& ChrW(^&H952E^) ^& ChrW(^&H83DC^) ^& ChrW(^&H5355^)
echo ask = ask ^& ChrW(^&H4E2D^) ^& ChrW(^&H6DFB^) ^& ChrW(^&H52A0^) ^& ChrW(^&H300C^) ^& title ^& ChrW(^&H300D^) ^& ChrW(^&H3002^)
echo ask = ask ^& vbCrLf ^& vbCrLf
echo ask = ask ^& ChrW(^&H662F^) ^& " = " ^& ChrW(^&H5B89^) ^& ChrW(^&H88C5^) ^& vbCrLf
echo ask = ask ^& ChrW(^&H5426^) ^& " = " ^& ChrW(^&H5378^) ^& ChrW(^&H8F7D^) ^& vbCrLf
echo ask = ask ^& ChrW(^&H53D6^) ^& ChrW(^&H6D88^) ^& " = " ^& ChrW(^&H9000^) ^& ChrW(^&H51FA^)
echo.
echo okIns = ChrW(^&H5B89^) ^& ChrW(^&H88C5^) ^& ChrW(^&H6210^) ^& ChrW(^&H529F^) ^& ChrW(^&H3002^) ^& vbCrLf ^& vbCrLf
echo okIns = okIns ^& ChrW(^&H8BF7^) ^& ChrW(^&H53F3^) ^& ChrW(^&H952E^) ^& ChrW(^&H70B9^) ^& ChrW(^&H51FB^)
echo okIns = okIns ^& ChrW(^&H4EFB^) ^& ChrW(^&H610F^) ^& ChrW(^&H6587^) ^& ChrW(^&H4EF6^) ^& ChrW(^&HFF0C^)
echo okIns = okIns ^& ChrW(^&H9009^) ^& ChrW(^&H62E9^) ^& ChrW(^&H300C^) ^& title ^& ChrW(^&H300D^) ^& ChrW(^&H3002^)
echo okIns = okIns ^& vbCrLf ^& vbCrLf
echo okIns = okIns ^& "Windows 11 " ^& ChrW(^&H8BF7^) ^& ChrW(^&H4F7F^) ^& ChrW(^&H7528^) ^& ChrW(^&H300C^)
echo okIns = okIns ^& ChrW(^&H663E^) ^& ChrW(^&H793A^) ^& ChrW(^&H66F4^) ^& ChrW(^&H591A^) ^& ChrW(^&H9009^) ^& ChrW(^&H9879^)
echo okIns = okIns ^& ChrW(^&H300D^) ^& ChrW(^&H6216^) ^& " Shift + " ^& ChrW(^&H53F3^) ^& ChrW(^&H952E^) ^& ChrW(^&H3002^)
echo.
echo okUn = ChrW(^&H5DF2^) ^& ChrW(^&H5378^) ^& ChrW(^&H8F7D^) ^& ChrW(^&H300C^) ^& title ^& ChrW(^&H300D^)
echo okUn = okUn ^& ChrW(^&H53F3^) ^& ChrW(^&H952E^) ^& ChrW(^&H83DC^) ^& ChrW(^&H5355^) ^& ChrW(^&H3002^)
echo.
echo If WScript.Arguments.Count ^< 1 Then
echo WScript.Quit 1
echo End If
echo appdir = WScript.Arguments(0^)
echo.
echo choice = MsgBox(ask, 3 + 32, title^)
echo If choice = 2 Then
echo WScript.Quit 0
echo End If
echo.
echo If choice = 6 Then
echo If Not fso.FolderExists(appdir^) Then
echo fso.CreateFolder appdir
echo End If
echo helper = fso.BuildPath(appdir, "rename-to-zip.vbs"^)
echo If Not fso.FileExists(helper^) Then
echo MsgBox "Helper script missing.", 16, title
echo WScript.Quit 1
echo End If
echo icon = sh.ExpandEnvironmentStrings("%%SystemRoot%%\system32\zipfldr.dll"^)
echo cmd = "wscript.exe //nologo """ ^& helper ^& """ ""%%1"""
echo If Not WriteMenu(True, icon, cmd^) Then
echo MsgBox "Registry write failed.", 16, title
echo WScript.Quit 1
echo End If
echo MsgBox okIns, 64, title
echo ElseIf choice = 7 Then
echo Call WriteMenu(False, "", ""^)
echo On Error Resume Next
echo If fso.FolderExists(appdir^) Then
echo fso.DeleteFolder appdir, True
echo End If
echo On Error GoTo 0
echo MsgBox okUn, 64, title
echo End If
echo.
echo Function WriteMenu(doInstall, iconPath, cmdLine^)
echo Dim key, keyCmd
echo key = "Software\Classes\*\shell\RenameToZip"
echo keyCmd = key ^& "\command"
echo WriteMenu = False
echo On Error Resume Next
echo Set reg = GetObject("winmgmts:\\.\root\default:StdRegProv"^)
echo If Err.Number ^<^> 0 Then
echo Set reg = Nothing
echo Err.Clear
echo End If
echo If doInstall Then
echo If Not reg Is Nothing Then
echo reg.CreateKey HKCU, key
echo reg.CreateKey HKCU, keyCmd
echo reg.SetStringValue HKCU, key, "", title
echo reg.SetStringValue HKCU, key, "Icon", iconPath
echo reg.SetStringValue HKCU, key, "NeverDefault", ""
echo reg.SetStringValue HKCU, key, "MultiSelectModel", "Document"
echo reg.SetStringValue HKCU, keyCmd, "", cmdLine
echo Else
echo sh.RegWrite "HKCU\" ^& key ^& "\", title, "REG_SZ"
echo sh.RegWrite "HKCU\" ^& key ^& "\Icon", iconPath, "REG_SZ"
echo sh.RegWrite "HKCU\" ^& key ^& "\NeverDefault", "", "REG_SZ"
echo sh.RegWrite "HKCU\" ^& key ^& "\MultiSelectModel", "Document", "REG_SZ"
echo sh.RegWrite "HKCU\" ^& keyCmd ^& "\", cmdLine, "REG_SZ"
echo End If
echo Else
echo If Not reg Is Nothing Then
echo reg.DeleteKey HKCU, keyCmd
echo reg.DeleteKey HKCU, key
echo End If
echo sh.RegDelete "HKCU\" ^& keyCmd ^& "\"
echo sh.RegDelete "HKCU\" ^& key ^& "\"
echo End If
echo If Err.Number = 0 Then
echo WriteMenu = True
echo Else
echo Err.Clear
echo WriteMenu = True
echo End If
echo On Error GoTo 0
echo End Function
)
goto :EOF