美文网首页
使用PowerShell压缩文件夹

使用PowerShell压缩文件夹

作者: 喷射的熔浆 | 来源:发表于2017-08-30 16:21 被阅读0次

Vivaldi数据迁移过程中,压缩用户数据文件夹如下。

# Vivaldi User Data Folder
$toArchive = Join-Path -Path $env:UserProfile -ChildPath "AppData\Local\Vivaldi\User Data\"

# where to store the zip file
$zipFileName = -join((Get-Date -Format "yyyyMMdd_"), 'userData.zip')
$destFolder = "D:\Backup\"
$filePath = Join-Path -Path $destFolder -ChildPath $zipFileName

 If(Test-path -Path $destFolder) {
    # OK
    if ( Test-Path -Path $filePath ){
        # alreay existed
        exit
    }else{
        Out-Host -InputObject " Archiving $toArchive"
        Out-Host -InputObject " to $filePath"
        $info = Compress-Archive -DestinationPath $filePath -Path $toArchive -CompressionLevel Optimal
        Out-Host -InputObject $info
    }
 }else{
    # disk is umounted or busy
    exit
 }

相关文章

网友评论

      本文标题:使用PowerShell压缩文件夹

      本文链接:https://www.haomeiwen.com/subject/ppfxjxtx.html