Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
控制文件列表中的powershell通配符_Powershell - Fatal编程技术网

控制文件列表中的powershell通配符

控制文件列表中的powershell通配符,powershell,Powershell,我有一个powershell脚本,它使用控制文件来归档文件: # Takes the information from $controlfile and moves the files to the archive folder** foreach ($line in get-content $controlfile) { $file = $controlfile $split = $line.split("|") $archive_path = $split[0] $source_path

我有一个powershell脚本,它使用控制文件来归档文件:

# Takes the information from $controlfile and moves the files to the archive folder**

foreach ($line in get-content $controlfile)
{
$file = $controlfile
$split = $line.split("|")
$archive_path = $split[0]
$source_path = $split[1]
$basename = $split[2]
$extention = $split[3]
$daystoleave = $split[4]

# move the files to the archive folder

Get-ChildItem $source_path -Filter "$basename*" -Force -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays($daystoleave)} | Move-Item -Destination $archive_path
Get-ChildItem $archive_path -Filter "$basename*" -Force -Recurse | % { rename-item –path $_.Fullname –Newname (("$basename") + ("_") + ($_.LastWriteTime.toString("MM.dd.yy_HH.mm.ss")) + (".$extension")) }
}
控制文件示例:

\服务器\应用程序\存档请求\| \服务器\应用程序\请求\|?| 0

\服务器\Apps\Archive Requests\|\server\Apps\Requests\|*|0

上面的例子不起作用,因为?或控制文件的文件名拆分中的*字符

\服务器\Apps\Archives\Archive|U Daily|U Reports\|\Apps\FICS\Daily Reports\|审计| FICS | 0

上面的示例之所以有效,是因为“audit”是文件名的开头

如果我想捕获并使用原始文件名的第一部分(例如SAD123.txt-capture SAD |将LastWriteTime日期添加到名称|添加扩展名|在原始文件夹中保留一些文件($daystoleave),则此操作非常有效

但是,如果我想使用通配符捕获整个原始名称或名称的中间部分,我会收到“路径中的非法字符”。并且最终结果文件名不会发生任何更改。在控制文件中是否可以使用除*或?以外的通配符


是否可以在控制文件中使用通配符?

请在OP中添加两个或三个精确样本以及每一行的精确结果。我真正的难题是“是否可以在控制文件中使用通配符?”