Windows Gezgini (en azından Windows XP) Zip dosyaları için bazı temel desteğe sahip olduğundan, komut satırı eşdeğeri olması gerektiği gibi görünüyor, ancak bir tanesinin işaretini bulamıyorum.
Windows (XP, Vista, 7, 8, 2003, 2008, 2013) yerleşik bir komut satırı Zip aracıyla birlikte mi geliyor yoksa üçüncü taraf araçlarına bağlı kalmam mı gerekiyor?
Windows'da yerleşik değildir, ancak Kaynak Seti Araçları'ndaCOMPRESS
,
C:\>compress /?
Syntax:
COMPRESS [-R] [-D] [-S] [ -Z | -ZX ] Source Destination
COMPRESS -R [-D] [-S] [ -Z | -ZX ] Source [Destination]
Description:
Compresses one or more files.
Parameter List:
-R Rename compressed files.
-D Update compressed files only if out of date.
-S Suppress copyright information.
-ZX LZX compression. This is default compression.
-Z MS-Zip compression.
Source Source file specification. Wildcards may be
used.
Destination Destination file | path specification.
Destination may be a directory. If Source is
multiple files and -r is not specified,
Destination must be a directory.
Örnekler:
COMPRESS temp.txt compressed.txt
COMPRESS -R *.*
COMPRESS -R *.exe *.dll compressed_dir
Farkında olduğumdan değil. Üçüncü taraf araçlar gittikçe, 7Zip oldukça güzel bir komut satırı arayüzüne sahiptir ve ikili uygulama, uygulamanızın dizininde uygulamanızla dağıtılabilir, bu nedenle vaktinden önce kurulmasına güvenmeniz gerekmez.
.Net 4.5 bu işlevselliğe sahiptir ve PowerShell tarafından kullanılabilir. Server 2012, Windows 8'de olmanız veya .Net 4.5'in manuel olarak yüklenmiş olması gerekir.
[Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
$Compression = [System.IO.Compression.CompressionLevel]::Optimal
$IncludeBaseDirectory = $false
$Source = "C:\Path\To\Source"
$Destination = "C:\CoolPowerShellZipFile.Zip"
[System.IO.Compression.ZipFile]::CreateFromDirectory($Source,$Destination,$Compression,$IncludeBaseDirectory)
Süper kullanıcı sitesinde bulunan başka bir çözüm .bat dosyasında windows native com nesnesini kullanır:
Bunun için tek bir basit PowerShell komutu var. (PowerShell v5.0 +)
Sıkıştırmak için:
Compress-Archive -LiteralPath 'C:\mypath\testfile.txt' -DestinationPath "C:\mypath\Test.Zip"
Sıkıştırmak için:
Expand-Archive -LiteralPath "C:\mypath\Test.Zip" -DestinationPath "C:\mypath" -Force
Kaynaklar:
@Ramhound'a özel teşekkürler