问题标签 [powershell-v5.1]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
powershell - 使用 PowerShell 5 或 > 更新 zipfile。正在寻找改进的工作代码
Windows 10 64 位。PowerShell 5.1
使用 PowerShell 5 或 > 更新 zipfile。正在寻找改进的工作代码。
使用 PowerShell 5 gci, regex, $Matches, foreach
{ $_ PadLeft },更新 zip 文件Compress-Archive, and Remove-Item
。平均 29 毫秒 9 个文件 (48KB) 10 次运行 3 个存档。
用于测试清除您的桌面。您的桌面上不应有 .txt 或 .zip 文件。有 3 个Remove-Item
没有-whatif
or -confirm
。制作 9 个文本文件和 3 个 zipfile。工作脚本、测试脚本、带日志文件的脚本。
制作测试文件并测试:
制作测试文件,十个带有日志文件的运行循环:
日志文件:
如何使用 powershell 解析多于一个点的文件路径、名称、基本名称。
如何将基本名称解析为第一个点。
如何使用 PadLeft。
如何使用 PowerShell 为字符串添加前导零和结尾零。
使用 PowerShell 5 或更高版本更新 zipfile。gci、get-childitem、regex、正则表达式、正则表达式、$Matches、foreach、管道中的当前项、$_、PadLeft、Compress-Archive 和 Remove-Item。在 10 次运行中,3 个存档中的 9 个文件 (48KB) 平均耗时 29 毫秒。