查看“︁7pk”︁的源代码
←
7pk
跳转到导航
跳转到搜索
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:{{spmono|7pk}}}} A tiny little script created for the convenience of archiving. If no file(s), folder(s) or filelist(s) (included with an <code>@</code> at the beginning of the filename of the filelist, for example, <code>@fl.txt</code>) were given, the script will archive everything in the current folder by default. This batch / bash script accepts optional switches as follows: * <code>'''-p'''</code> or <code>'''-p*'''</code>: sets the password for the archive; if no password is provided ''immediately'' attached to the <code>-p</code> switch (means you have to write in the form of <code>-p123WSX</code>), then 7-zip will prompt for a password to be set; * <code>'''-o'''</code>: sets the name of the archive; if no <code>-o</code> switch is found, the script will then pack the given files into a {{spmono|.7z}} archive with a 6-digit date string and a 4-digit time string (separated by a hyphen) of the time accurate to the minute of the archive being made as its filename; if <code>-o</code> is found, then the given filename will surpass the default naming pattern; this switch also accepts three naming cards as follows: ** <code>'''['''</code>: if a <code>[</code> (left square bracket) is detected at the beginning of the given filename string (excluding the part of path—if specified) but no <code>]</code> (right square bracket) is found in the rest part of that string, then a 6-digit date wrapped in square brackets will be added to the beginning of the filename, followed by a space character and the rest of the given filename ''without'' the leading <code>[</code>; for example, <code>-o [abc</code> shall produce something like ‘{{spmono|[{{#time:ymd|now|en}}] abc.7z}}’, where ‘{{spmono|{{#time:ymd|now|en}}}}’ stands for the date of the archive being made; ** <code>'''_'''</code>: if a <code>_</code> (underscore) is detected at the end of the given filename string (excluding the part of path—if specified), then a 6-digit date string and a 4-digit time string (separated by a hyphen) will be appended to the end of the filename ''without removing'' the given underscore; for example, <code>-o abc_</code> shall be processed into ‘{{spmono|abc_{{#time:ymd-Hi|now|en}}.7z}}’, where ‘{{spmono|{{#time:ymd-Hi|now|en}}}}’ stands for the date and time of the archive being made; ** <code>'''`'''</code> or <code>'''='''</code>: if a <code>`</code> (backtick) is detected while using the batch script on Windows or an <code>=</code> (equals sign) is detected while using the bash script on Linux ''anywhere'' in the given filename string (excluding the part of path—if specified), then the <code>`</code> (on Windows) or the <code>=</code> (on Linux) will be replaced with the name of the current directory; for example, if the current directory is named ‘{{spmono|abc}}’, and if <code>-o "[def `_"</code> is passed to the script on Windows or if <code>-o "[def =_"</code> is passed to the script on Linux, then the final filename shall be ‘{{spmono|[{{#time:ymd|now|en}}] def abc_{{#time:ymd-Hi|now|en}}.7z}}’; ** the script will automatically remove any leading or trailing spaces in the filename of the archive and trim consecutive spaces of more than one into one, which means if the name of the current directory contains consecutive spaces and if it is referenced in the filename of the archive, it will be trimmed, but this won’t affect the path designated for the archive—if indeed specified with the filename, and if the path contains leading, trailing or consecutive spaces—these spaces in the path will be left untreated; and ** the script will also automatically detect and deal with the existence (or the non-existence) of the file extension in the given filename, to wit, ‘{{spmono|.7z}}’—if there is no extension given, it will be added automatically, and if there is an extension in the given filename, it won’t be added repeatedly; * <code>'''-r'''</code>: passes <code>-r</code> switch to 7-zip to archive files recursively; * <code>'''-r0'''</code>: passes <code>-r0</code> switch to 7-zip to archive files recursively only on filenames with wildcards; and * <code>'''-ep'''</code>: passes <code>-spf2</code> switch to 7-zip to set the archive to use full paths without drive letter. The default dictionary size is set to 1 GB, feel free to change it in line 100 ({{spmono|7pk.bat}} for Windows) or line 73 ({{spmono|7pk}} for Linux) if it is too big or too small. A special note on using <code>-p*</code> to directly pass passwords to 7-zip: use <code>"-p12,3W;SX!"</code> to pass password <code>12,3W;SX!</code> to 7-zip on Windows when using this batch; on Linux, both <code>"-p12,3W;SX!"</code> and <code>-p"12,3W;SX!"</code> would work. For passwords containing special characters or spaces, this section shall always be quoted. To avoid untold marginal cases, it is recommended to use the bare <code>-p</code> and let 7-zip to prompt request for a password if the password to be set is too complex. ==Windows== Make sure 7-zip is installed and the location where 7-zip is installed is added to {{spmono|%PATH%}}. {{7pk-win}} ==A WinRAR diversion== Make sure WinRAR is installed and the location where WinRAR is installed is added to {{spmono|%PATH%}}. The following batch script functions very similar to the one using 7-zip above—after all, the one below is just an altered version of the one above. But it does have some exclusive features courtesy of WinRAR: * the <code>-r</code> switch is now enabled by default, it can only be turned off if the user explicitly demands so by applying <code>'''-rn'''</code>, <code>'''-nr'''</code> or simply <code>'''-n'''</code>—mind you, if you turns off <code>-r</code> when using WinRAR, then the application will really mean it and will not archive files recursively whatsoever, in any case, at all; it follows a logic that differs from the way 7-zip does it; * the <code>'''-ep'''</code> switch obviously won’t pass <code>-spf2</code> to WinRAR, but the equivalent <code>-ep2</code>—in fact, as you can see, I named this switch in the script after the switch in WinRAR, as <code>-p</code> is already taken for password; and * there is a <code>'''-k'''</code> switch to ‘lock’ the archive and a <code>'''-e'''</code> (or <code>'''-ed'''</code>) switch to exclude empty folders when archiving—both are exclusive to WinRAR and cannot be achieved with 7-zip. The default dictionary size is set to 8 GB, feel free to change it in line 127 if it is too big or too small. {{rpk-win}} ==Linux== {{7pk-linux}} Moreover, the latest (and official) 7-zip binary can be downloaded and put into <code>/user/local/bin/</code> with the script below: {{install-7z-linux}} ==And the other one== (Translated by [[wikipedia:Grok_(chatbot)|Grok]], not fully tested, should be fine.) {{7pk-zsh}} __NOTOC__
此页面嵌入的页面:
Template:7pk-linux
(
查看源代码
)
Template:7pk-win
(
查看源代码
)
Template:7pk-zsh
(
查看源代码
)
Template:Install-7z-linux
(
查看源代码
)
Template:NB
(
查看源代码
)
Template:Rpk-win
(
查看源代码
)
Template:Spmono
(
查看源代码
)
Template:Stbgn
(
查看源代码
)
Template:Stblu
(
查看源代码
)
Template:Stsbl
(
查看源代码
)
返回
7pk
。
导航菜单
个人工具
登录
命名空间
页面
讨论
不转换
不转换
简体
繁體
大陆简体
香港繁體
澳門繁體
大马简体
新加坡简体
臺灣正體
查看
阅读
查看源代码
查看历史
更多
搜索
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
工具
链入页面
相关更改
页面信息