标题: [文件管理] 用 WinRAR + Windows 右键发送到 (SendTo) 给文件或目录快速打包[带实时时间命名后缀] [打印本页]
作者: aa77dd@163.com 时间: 2016-10-3 03:24 标题: 用 WinRAR + Windows 右键发送到 (SendTo) 给文件或目录快速打包[带实时时间命名后缀]
此脚本无参数运行时, 将把自身复制到 SendTo 目录
在单一文件或者单一目录[无论文件或目录都只支持一个, 但目录内可含有任意层子目录及任意个文件]上点右键菜单发送到 ==> 此脚本文件名 时
将为该文件/目录创建一个带实时时间后缀的压缩包, 和源文件在同一目录下
例: 源文件名 file.txt, 压缩包名 file-20161003_025808.zip
ftype 是压缩格式 zip 或者 rar 可选
mmode 是压缩比, 范围 0--5 0 最低, 5 最高
pwd 是密码, 用你需要的密码替换即可, 此密码会被加入压缩包的明文中,
因本人最初目的只为备份及简单防毒.
可以把本文件修改另存为几个副本, 比如我用了 6 种设置, 如下图- @echo off & chcp 936
-
- :: +--------------------------------------------------+
- :: |# _添加到加密同名压缩文件(.rar)_-m3.CMD |
- :: |# _添加到加密同名压缩文件(.rar)_存储-m0.CMD |
- :: |# _添加到加密同名压缩文件(.rar)_最好-m5.CMD |
- :: _____ |# _添加到加密同名压缩文件(.zip)_-m3.CMD |
- :: | .. |\ |# _添加到加密同名压缩文件(.zip)_存储-m0.CMD |
- :: | .. |_\ |# _添加到加密同名压缩文件(.zip)_最好-m5.CMD |
- :: | ,,,, | |B Bluetooth设备 |
- :: | ....+---------------|M 传真收件人 |
- :: |_____| 打开(O) | 文档 |
- :: file.t|# ..... | 压缩(zipped)文件夹 |
- :: |# | 邮件接收人 |
- :: |$ ... | 桌面快捷方式 |
- :: | | DVD RW 驱动器(F:) |
- :: | 发送到(N) > +--------------------------------------------------+
- :: | |
- :: | |
- :: | 属性(R) |
- :: +---------------+
-
-
- setlocal enableDelayedExpansion
-
- set "ftype=zip" & REM 压缩格式 ftype: zip 或者 rar
-
- set "mmode=3" & REM 压缩比 mmode: [0,5] 5 最高, 0 最低
-
- set "pwd=yourpassword" & REM 为压缩包设定一个密码, 此密码将在压缩包注释中可见
-
- REM 如果空参数运行, 将本文件复制到 SendTo 目录中
- if "%~1"=="" (
-
- for /f tokens^=2* %%a in ('reg query "HKCU\software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /v SendTo ^| find /i "REG_SZ"') do (
- echo;copy /y "%~0" "%%~b\"
- copy /y "%~0" "%%~b\"
- )
- echo;任意键退出...
- >nul pause
- exit
- )
-
-
- REM 生成随机标记串
- set "neorand=neorand_"
- for /l %%a in (1 1 5) do (
- set "neorand=!neorand!!random:~-1!"
- )
- echo;随机标记串
- set neorand
-
-
- REM 搜索出 winrar 的全路径
- set "filename=winrar.exe"
- call :searchFile winrarFullname
- echo;winrar 的全路径
- echo;winrarFullname={!winrarFullname!}
-
- set "r_param="
- if exist "%~1\" (
- set "r_param=-r"
- )
-
- echo;"%winrarFullname%" a -ag-YYYYMMDD_HHMMSS -m%mmode% -af%ftype% "%~dp1!neorand!%~n1.%ftype%" -p%pwd% %r_param% -ep1 "%~1"
- "%winrarFullname%" a -ag-YYYYMMDD_HHMMSS -m%mmode% -af%ftype% "%~dp1!neorand!%~n1.%ftype%" -p%pwd% %r_param% -ep1 "%~1"
-
- REM 生成注释文件
- > "%~dp0rarcomment.txt" (
- echo;"%~n1.%ftype%" 生成于 %date%_%time%
- echo;pwd
- echo;!pwd!
- )
-
- REM 找出含有 随机标记串 前缀 日期时间 后缀 的压缩文件名
- set "arcname="
- for /f "delims=" %%a in ('dir /s /b "%~dp1!neorand!%~n1*.%ftype%"') do (
- if "!arcname!"=="" (
- set "arcname=%%~a"
- )
- )
- echo;含有 随机标记串 前缀 日期时间 后缀 的压缩文件名
- set arcname
-
- REM 添加注释
- "%winrarFullname%" c -z"%~dp0rarcomment.txt" "!arcname!"
- del "%~dp0rarcomment.txt"
-
- REM 去掉 随机标记串
- for %%a in ("!arcname!") do (
- REM echo;%%~nxa
- set "fn=%%~nxa"
- set "fn=!fn:~13!"
- )
-
- ren "!arcname!" "!fn!"
-
- title 压缩包已经生成, 按任意键退出...
- <nul set /p "=压缩包已经生成, 按任意键退出..."
- >nul pause
-
- exit
-
-
- :searchFile winrarFullname
-
- setlocal enableDelayedExpansion
- set "rt="
-
- for %%d in (C D E) do (
- if "!rt!"=="" (
- for %%V in ("ProgramFiles" "ProgramFiles(x86)" "ProgramData" "ProgramW6432") do (
- if "!rt!"=="" if "!%%~V!" neq "" (
-
- for /f "delims=" %%p in ('dir "%%d!%%~V:~1!\!filename!" /a /s /b') do (
- if "!rt!"=="" if /i "%%~nxp"=="!filename!" (
- set "rt=%%~p"
- )
- )
- )
- )
- )
- )
-
- if "!rt!"=="" (
- for %%d in (C D E F G H I J K L M N O P Q R S T U V W X Y Z) do (
- if "!rt!"=="" (
- for /f "delims=" %%p in ('dir %%d:\"!filename!" /a /s /b') do (
- if "!rt!"=="" if /i "%%~nxp"=="!filename!" (
- set "rt=%%~p"
- )
- )
- )
- )
- )
-
- ( endlocal & REM RETURN VALUES
- if "%~1" NEQ "" (set %~1=%rt%) else (echo;%rt%)
- exit /b
- )
-
- exit /b
-
- REM wmic 方式搜索文件, 慢
- :searchFile_wmic winrarFullname
- setlocal enableDelayedExpansion
- set "rt="
- for /f %%d in ('wmic logicaldisk get deviceid^|more +1') do (
- if "!rt!"=="" (
- for /f "delims=" %%p in ('dir %%d\"!filename!" /a /s /b') do (
- if "!rt!"=="" if /i "%%~nxp"=="!filename!" (
- set "rt=%%~p"
- )
- )
- )
- )
-
- ( endlocal & REM RETURN VALUES
- if "%~1" NEQ "" (set %~1=%rt%) else (echo;%rt%)
- exit /b
- )
- exit /b
复制代码
作者: 我来了 时间: 2016-10-3 07:43
楼先生,我们使用 多个注册表来完成以上类似的操作。
作者: aa77dd@163.com 时间: 2016-10-3 09:00
回复 2# 我来了
楼妹子, 请把你的注册表借我瞅瞅呗- ヘ^ヽ、 /⌒、 _,_
- |  ̄7 (⌒r⌒7/
- レ \_/ ̄\_」
- _/ {
- _フ ● ゝ
- _人 ο ● ナ
- `ト、_ メ
- /  ̄ ーィ゙
- 〈゚・。。。・゚ 丶
复制代码
作者: 我来了 时间: 2016-10-3 10:33
回复 3# aa77dd@163.com
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\WinRAR\Profiles]
[HKEY_CURRENT_USER\Software\WinRAR\Profiles\0]
"Name"="加密码 加注释1"
"Default"=dword:00000001
"ImmExec"=dword:00000001
"ExclNames"=""
"StoreNames"=""
"UseRAR"=dword:00000001
"RAR5"=dword:00000000
"SFXModule"=""
"SFXIcon"=""
"SFXLogo"=""
"SFXElevate"=dword:00000000
"CmtFile"="D:\\注释.txt"
"CmtDataWide"=hex:00,00
"VolumeSize"="0"
"VolSizeMod"=dword:00000000
"VolPause"=dword:00000000
"OldVolNames"=dword:00000000
"RecVolNumber"=dword:00000000
"Update"=dword:00000000
"Fresh"=dword:00000000
"SyncFiles"=dword:00000000
"Overwrite"=dword:00000000
"Move"=dword:00000001
"ArcRecBin"=dword:00000000
"ArcWipe"=dword:00000000
"WipeIfPassword"=dword:00000000
"Solid"=dword:00000000
"Test"=dword:00000000
"RecEnabled"=dword:00000000
"RecSize"=dword:fffffffd
"EraseDest"=dword:00000000
"AddArcOnly"=dword:00000000
"ClearArc"=dword:00000000
"Lock"=dword:00000000
"Method"=dword:00000005
"DictSizeLZ"=dword:00400000
"DictSize"=dword:02000000
"Background"=dword:00000000
"WaitForOther"=dword:00000000
"Shutdown"=dword:00000000
"PasswordWide"=hex:37,3c,ed,12,51,2a,75,50,d4,df,25,32,1d,24,08,58,9b,3b,3b,13,\
15,2c,00,60,0e,ed,95,2a,68,32,67,68
"EncryptHeaders"=dword:00000000
"OpenShared"=dword:00000000
"ProcessOwners"=dword:00000000
"SaveStreams"=dword:00000000
"SaveSymLinks"=dword:00000000
"SaveHardLinks"=dword:00000000
"GenerateArcName"=dword:00000000
"VersionControl"=dword:00000000
"BLAKE2"=dword:00000000
"FileCopies"=dword:00000000
"QuickOpen"=dword:00000001
"GenerateMask"="yyyymmddhhmmss"
"FileTimeMode"=dword:00000000
"FileDays"=dword:00000000
"FileHours"=dword:00000000
"FileMinutes"=dword:00000000
"FileTimeBefore"=dword:0a214000
"FileTimeAfter"=dword:0a214000
"ArcTimeOriginal"=dword:00000000
"ArcTimeLatest"=dword:00000000
"mtime"=dword:00000004
"ctime"=dword:00000000
"atime"=dword:00000000
"PathsAbs"=dword:00000000
"PathsNone"=dword:00000000
"PathsAbsDrive"=dword:00000000
"SeparateArc"=dword:00000000
"EmailArcTo"=""
"PackDetails"=hex:00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"AddToMenu"=dword:00000001
[HKEY_CURRENT_USER\Software\WinRAR\Profiles\1]
"Name"="生成弹出网页EXE 加注释 加密码2"
"Default"=dword:00000000
"ImmExec"=dword:00000001
"ExclNames"=""
"StoreNames"=""
"UseRAR"=dword:00000001
"RAR5"=dword:00000000
"SFXModule"="D:\\WinRAR\\winrar\\Default.SFX"
"SFXIcon"=""
"SFXLogo"=""
"SFXElevate"=dword:00000000
"CmtFile"="D:\\注释2.txt"
"CmtDataWide"=hex:00,00
"VolumeSize"="0"
"VolSizeMod"=dword:00000000
"VolPause"=dword:00000000
"OldVolNames"=dword:00000000
"RecVolNumber"=dword:00000000
"Update"=dword:00000000
"Fresh"=dword:00000000
"SyncFiles"=dword:00000000
"Overwrite"=dword:00000000
"Move"=dword:00000001
"ArcRecBin"=dword:00000000
"ArcWipe"=dword:00000000
"WipeIfPassword"=dword:00000000
"Solid"=dword:00000000
"Test"=dword:00000000
"RecEnabled"=dword:00000000
"RecSize"=dword:fffffffd
"EraseDest"=dword:00000000
"AddArcOnly"=dword:00000000
"ClearArc"=dword:00000000
"Lock"=dword:00000000
"Method"=dword:00000005
"DictSizeLZ"=dword:00400000
"DictSize"=dword:02000000
"Background"=dword:00000000
"WaitForOther"=dword:00000000
"Shutdown"=dword:00000000
"PasswordWide"=hex:37,3c,ed,12,51,2a,75,50,d4,df,25,32,1d,24,08,58,9b,3b,3b,13,\
15,2c,00,60,0e,ed,95,2a,68,32,67,68
"EncryptHeaders"=dword:00000000
"OpenShared"=dword:00000000
"ProcessOwners"=dword:00000000
"SaveStreams"=dword:00000000
"SaveSymLinks"=dword:00000000
"SaveHardLinks"=dword:00000000
"GenerateArcName"=dword:00000000
"VersionControl"=dword:00000000
"BLAKE2"=dword:00000000
"FileCopies"=dword:00000000
"QuickOpen"=dword:00000001
"GenerateMask"="yyyymmddhhmmss"
"FileTimeMode"=dword:00000000
"FileDays"=dword:00000000
"FileHours"=dword:00000000
"FileMinutes"=dword:00000000
"FileTimeBefore"=dword:0a214000
"FileTimeAfter"=dword:0a214000
"ArcTimeOriginal"=dword:00000000
"ArcTimeLatest"=dword:00000000
"mtime"=dword:00000004
"ctime"=dword:00000000
"atime"=dword:00000000
"PathsAbs"=dword:00000000
"PathsNone"=dword:00000000
"PathsAbsDrive"=dword:00000000
"SeparateArc"=dword:00000000
"EmailArcTo"=""
"PackDetails"=hex:00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
"AddToMenu"=dword:00000001
作者: aa77dd@163.com 时间: 2016-10-3 11:09
回复 4# 我来了
多谢啦- _ _
- ( \/ )
- .---. \ / .-"-.
- / 6_6 \/ / 4 4 \
- \_ (__\ \_ v _/
- // \\ // \\
- (( )) (( ))
- =======""===""========""===""=======
- ||| THANKS |||
- | |
复制代码
作者: 我来了 时间: 2016-10-3 11:44
回复 5# aa77dd@163.com
我还有N多修改注册表的秘方
作者: aa77dd@163.com 时间: 2016-10-3 11:53
回复 6# 我来了
馋我啊- ==
- ==
- ==
- `````````` ==
- ```==========``` ==
- /\```/\================`````==
- ( O O )=====================
- === ^ === ================
- \ O / ==================
- ''' ====== =====
- ==== ====
- === ===
- == ==
- == ==
- == ==
- WW WW
- '' ''
复制代码
作者: 我来了 时间: 2016-10-3 16:25
回复 7# aa77dd@163.com
俺98年就玩注册表了
作者: aa77dd@163.com 时间: 2016-10-3 17:09
回复 8# 我来了
98年, 我没见过 Windows, 只见过 DOS , 更没有自己的电脑
作者: plp626 时间: 2016-10-4 19:15
回复 1# aa77dd@163.com
找rar目录可以用ftype,复制代码
作者: aa77dd@163.com 时间: 2016-10-4 19:23
回复 10# plp626
Thanks!
试了下, Win7 / XP 都有 ftype
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |