powershell - Powershell复制具有特定数字的多个文件
问题描述
对 Powershell 来说仍然很新,我想将多个文件从一台服务器复制到另一台服务器。我要复制的文件包含相同的两个数字 18 或 19。
Copy-Item -Path \\test\files\07_Export -Filter '*18.csv' -Destination \\test01\files$\2018;
Copy-Item -Path \\test\files\07_Export -Filter '*19.csv' -Destination \\test01\files$\2019;
例如 Test18.csv
问题19.csv
搜索18.csv
现在它只是复制空文件夹 07_export。
解决方案
这应该符合您的目的。
$filename = (Get-ChildItem "<Source Folder>" -Recurse | Where-Object { $_.FullName -imatch "18" -or $_.FullName -imatch "19" }).FullName
foreach ($file in $filename) {
Copy-Item -Path $file -Destination "<Destination Folder>"
}
推荐阅读
- php - 使用 PHP 检查文件是否已加密
- android - 通过蓝牙将 2 个 arduino 连接到同一个 Android Flutter 应用程序
- amazon-web-services - 如何在 aws codebuild worker 容器中安装 deb 包
- facebook - Facebook App Dashboard 中的“允许域”如何工作
- postgresql - Postgres 插入/更新 ~11.000.000 行
- google-schemas - TrainReservation 标记对电子邮件没有影响
- python - 如何遍历列名并对 Pandas 中的每一列执行相同的过程
- r - 按范围分组并计算 R 和图形中的平均值
- sql - 选择表中的异常值
- javascript - 如何使用文本输入字段从数组中添加和删除项目