나는 아래 보이는 작동하는 것처럼 보이지만 성능에 영향을 줄 수 있다고 생각 될 때마다 오류를 인쇄합니다. 이 오류가 발생하는 이유는 무엇입니까?powershell 스크립트의 오류
오류 :
Move-Item : Cannot find path 'C:\Program Files (x86)\mailserver\mail\domain.com\user\inbox\201012090411577967.imap' because it does not exist.
At C:\scripts\findfiles.ps1:27 char:21
+ $list | foreach { mv <<<< $_.Path $newdir }
+ CategoryInfo : ObjectNotFound: (C:\Program File...0411577967.imap:String) [Move-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.MoveItemCommand
파워 쉘 스크립트
$list = gci $startdir* -include "*.imap" -recurse | where { select-string -Path $_ -Pattern $pattern -Quiet }
당신도 할 수 있습니다 :
# Prompt the user for a start directory
$startdir=Read-Host "Enter a directory to search (without trailing slash)"
# Define a variable for the new directory
$newdir="$startdir\temp"
# Make the temp directory
if (!(Test-Path -path $newdir))
{
New-Item $newdir -type directory
}
# Tell them we will write to the start director\temp
write-host "Files will be moved to $newdir"
# Prompt to a pattern to search for
$pattern=Read-Host "Enter a pattern to search for"
# Tell the user we are doing something
write-host "Searching $startdir for `"$pattern`" then moving. Please wait...."
# Generate a list of files containing a pattern
$list = gci $startdir\* -include "*.imap" -recurse | select-string -pattern $pattern
# Move files matching the pattern to temp
$list | foreach { mv $_.Path $newdir }
정확하게 문제가있었습니다. 그것은 총체적으로 이해합니다. 나는 왜 내가 그것을 생각하지 않았는지 모르겠습니다. 정말 고맙습니다!! – Brad