powershell - Powershell 解压缩扩展名为 .zip 的文件并将其移动到另一个文件夹
问题描述
我希望你们中的一些人可以帮助我。我在修改 powershell 脚本时遇到了困难。
该脚本检查特定文件夹(源)中的 zip 文件(文件名是固定值)并将其移动到另一个文件夹(目标),但是我需要一个脚本来检查 .zip 扩展名,而不是固定值和也将其移动到另一个文件夹。我现在正在使用这个脚本:
powershell.exe -nologo -noprofile -command "& { $shell = New-Object -COM Shell.Application; $target = $shell.NameSpace('D:\Anlagen'); $zip = $shell.NameSpace('C:\Temp\Rechnungen\Outlook'); $target.CopyHere($zip.Items(), 16); }"
如您所见,我需要将此脚本作为批处理文件。
解决方案
用于Expand-Archive
将文件解压缩到一个目录,然后从您的批处理脚本中,将文件复制到其他地方。如果您需要从批处理脚本执行此操作:
powershell.exe -c "Expand-Archive -Path 'C:\path\to\archive.zip' -DestinationPath 'C:\unzip\directory'"
xcopy /s /e /t "C:\unzip\directory" "C:\final\destination\directory"
请注意,UNC 路径也应与任一命令一起使用,而不仅仅是本地路径。
推荐阅读
- angularjs - 如何使用 VSCode 工具调试 jasmine 业力测试
- javascript - 一旦用户使用通过电子邮件发送的电子邮件验证链接进行验证,如何自动登录用户
- java - 使用 Elastic BeansTalk CLI 部署 Spring Boot 应用程序
- selenium - ChromeDriver 和带有 pageLoadStrategy 的 Chrome 的非确定性行为 none
- google-maps - 谷歌地图按时间出发
- java - kafka java进程消耗太多内存
- c# - Log4Net - 不要汇总文件
- javascript - Angular 中的主题订阅被调用两次以进行下一个方法调用
- javascript - React,为什么要使用 Redux
- linux - 带有 if not 条件的 Bash 循环