windows - 如何使用 PowerShell 将具有多个扩展名的文件集移动到另一个目录?
问题描述
我需要将一组具有不同扩展名的特定文件移动到另一个文件夹。
我在目录中有以下过滤文件。
文件1.txt 文件2.xml 文件3.dll
我已将上述文件保存在变量中$files
,我需要将每个文件移动到另一个文件夹。
下面是我试过的代码。
foreach ($fileType in $files) {
Get-ChildItem -Path C:\Files -Filter "$fileType*." -Recurse |
Move-Item -Destination C:\Dest
}
我收到以下错误
Get-ChildItem : 路径中的非法字符。 在行:1 字符:38 + ... lude_files){Get-ChildItem -Path C:\Files
感谢是否有人可以提供帮助?
解决方案
一个简单的方法来做到这一点
ls C:\files | Foreach {
Move-Item -Path C:\files\$filetype -Destination C:\dest
}
推荐阅读
- sql - Oracle SQL 窗口优化/可能的 Oracle PL/SQL 解决方案?
- fonts - 拒绝加载字体 '
' 因为它违反了以下内容安全策略指令:“font-src *” - android - 如何使用从适配器到其他类的捆绑包?
- powershell - Power Shell 脚本 SMTP 电子邮件问题
- javascript - webpack style-loader 将 css 显示为 style 标签内的 base64 编码字符串
- java - listview 是空的,我发现一个错误,但我无法解决它
- javascript - 无法使用 AngularJS 1 在 routeProvider 中使用查询参数进行路由
- java - 根据正确的月份在 ListView 中显示值
- python - 为指定的 n 创建所有布尔组合
- php - Braintree 使用测试信用卡进行 3D 安全交易