首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何筛选以数字[0-9]开头的文件

如何筛选以数字[0-9]开头的文件
EN

Stack Overflow用户
提问于 2020-01-03 01:44:09
回答 1查看 353关注 0票数 0

我有一个powershell脚本,可以将文件从一个文件夹复制到另一个文件夹。

代码语言:javascript
运行
复制
$files = Get-ChildItem "\\source" -filter "1*.835" | select Name,CreationTime

foreach ($f in $files){
if (-Not (Test-Path -Path "G:\destination\$($f.name)") -and -Not (Test-Path -Path 
"G:\destination\$($f.name)") -and $f.CreationTime -ge  "4/24/2019"){
Copy-Item -Path "\\source\$($f.Name)" -Destination 'G:\835'
}}
$filenames = New-Object 'System.Collections.Generic.List[String]'


$files = Get-ChildItem "G:\835" -Filter '*.835' | select Name

我需要改变:

代码语言:javascript
运行
复制
$files = Get-ChildItem "\\source" -filter "1*.835" | select Name,CreationTime

类似这样的东西:

代码语言:javascript
运行
复制
 $files = Get-ChildItem "\\source\*.835" | ? { $_.Name -match "[0- 9]*.835" } | Where-Object {$_.CreationTime -gt "12/21/2019" -and $_.CreationTime -lt "01/02/2020"} | select Name,CreationTime
EN

回答 1

Stack Overflow用户

发布于 2020-01-03 02:12:36

我把它改成了:

代码语言:javascript
运行
复制
    $files = Get-ChildItem "\\source\[0-9]*.835" | select Name,CreationTime
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59567683

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档