Repository navigation
Expand file tree
/
Copy pathtar7z.cmd
More file actions
118 lines (100 loc) · 3.23 KB
/
Copy pathtar7z.cmd
File metadata and controls
118 lines (100 loc) · 3.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
@ECHO OFF
:: https://stackoverflow.com/questions/53283240/how-to-create-tar-file-with-7zip
:: To compress general files.
:: -sccUTF-8: console output UTF-8
:: -bt: show time statistics
:: -slp: use large memory pages
:: -mx1: compression level fastest (key factor for compression speed)
:: -md=28: dictionary size 2^28=256MB (key factor for compression ratio)
:: -mmf=hc4: match finder hc4 (hash chain 4B, key factor for compression speed)
:: -mfb=273: word size 273B
:: -ms=4g: solid block size 4GB
:: -mmt: multithreading (use all CPU cores)
:: -mmtf: multithreading for filters
:: -myx: analyze all files
:: -mqs: sort by type (better compression ratio)
:: -mhe: encrypt archive header
SET __7z_lzma_args__=-sccUTF-8 -bt -slp -mx1 -md=28 -mfb=273 -ms=4g -mmt -mmtf -myx -mqs -mhe
:: To compress x86/x64 executables.
:: -mf=BCJ2::d27
:: use BCJ2 filter (for x86 executables)
:: d27: dictionary size 2^27=128MB
SET __7z_bcj_args__=-mf=BCJ2:d=27
:: To compress with hard and symbolic links.
:: -snh: keep hard links
:: -snl: keep symbolic links
SET __7z_tar_args__=-sccUTF-8 -snh -snl
:: To compress general files.
:: -sccUTF-8: console output UTF-8
:: -bt: show time statistics
:: -slp: use large memory pages
:: -mx1: compression level fastest (key factor for compression speed)
:: -md=28: dictionary size 2^28=256MB (key factor for compression ratio)
:: -mmf=hc4: match finder hc4 (hash chain 4B, key factor for compression speed)
:: -mfb=273: word size 273B
:: -ms=4g: solid block size 4GB
:: -mmt: multithreading (use all CPU cores)
:: -mmtf: multithreading for filters
:: -myx: analyze all files
SET __7z_xz_args__=-sccUTF-8 -bt -slp -mx1 -md=28 -mfb=273 -ms=4g -mmt -myx
:: tar7z <command> <arguments>
:: command:
:: a: add
:: aJ: add tar.xz
:: at: add tar.7z
:: x: extract
:: xt: extract tar.7z
IF "%~1"=="a" (
CALL :Add7z%*
) ELSE IF "%~1"=="aJ" (
CALL :AddTarXz%*
) ELSE IF "%~1"=="at" (
CALL :AddTar7z%*
) ELSE IF "%~1"=="x" (
CALL :Extract7z%*
) ELSE IF "%~1"=="xt" (
CALL :ExtractTar7z%*
)
SET __7z_archive__=
EXIT /B
========= Add7z =========
:Add7za
:: a: add to archive
7z.exe a %__7z_lzma_args__% %*
EXIT /B
========= AddTarXz =========
:AddTarXzaJ
:: a: add to archive
:: dummy: the output file name, not actually created, due to write to stdout
:: -ttar: create tarball
:: -so: write to stdout
:: -si: read from stdin
7z.exe a dummy -ttar -so %__7z_tar_args__% "%~1" | 7z.exe a -txz -si %__7z_xz_args__% "%~1.tar.xz"
EXIT /B
========= AddTar7z =========
:AddTar7zat
:: a: add to archive
:: dummy: the output file name, not actually created, due to write to stdout
:: -ttar: create tarball
:: -so: write to stdout
:: -si: read from stdin
7z.exe a dummy -ttar -so %__7z_tar_args__% "%~1" | 7z.exe a -si %__7z_lzma_args__% "%~1.tar.7z"
EXIT /B
========= Extract =========
:Extract7zx
:: x: extract with full paths
:: -si: read from stdin
:: -bt: show time statistics
:: -sccUTF-8: console output UTF-8
7z.exe x -bt -sccUTF-8 "%~1"
EXIT /B
========= Extract =========
:ExtractTar7zxt
:: e: extract without paths (it is a tarball)
:: x: extract with full paths
:: -so: write to stdout
:: -si: read from stdin
:: -bt: show time statistics
:: -sccUTF-8: console output UTF-8
7z.exe e -so "%~1" | 7z.exe x -ttar -si -bt -sccUTF-8
EXIT /B