2017-01-26 1 views
1

폴더 및 하위 폴더의 이미지 크기를 줄이는 스크립트가 있습니다. 그러나 일부 폴더를 제외하고 싶습니다.폴더를 제외하려면 이미지 크기 줄이기

나는 $source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list}이라는 매개 변수를 찾았지만 하나의 폴더 만 제외하고 여러 개를 제외 할 수 있습니다.

$source = "U:\TEST\Compression\images" 
$exclude_list = @('Imprimerie') 

$source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list} 

해결책이 있으십니까?

+2

: 'IMPRIMERIE | Imprimerie1abc'를 ... 전체 이름은 전체 경로와 일치하기 때문 또한 내가 $ _ 이름에 일치하는 것이 좋습니다 것입니다.을. ps_container -eq $ true – Kiran

+0

[Get-ChildItem의 항목 목록을 powershell에서 제외시키는 방법]의 가능한 복제본 (http://stackoverflow.com/questions/19207991/how-to) -exclude-list-of-items-from-childitem-result-in-powershell) –

+0

도움을 주셔서 감사합니다 !! – pcarrey

답변

1

match/notmach 사업자는 코드가 폴더 '목록 파이프 기호 alternation을 사용하는 것입니다 해결하기 위해 정규 표현식 (정규식) 그래서에게 가장 쉬운 솔루션을 사용 . 그래서 같은 문자열 같은 excludelist 만들기

$source = "U:\TEST\Compression\images" 
[regex] $exclude_list = “(Imprimerie|TestAnotherName)” 

$source_listephotos = Get-ChildItem $source -Recurse | where {$_.FullName -notmatch $exclude_list} 
+1

답장을 보내 주셔서 감사합니다. 시도하고 스크립트가 원하는대로 작동합니다. – pcarrey

2

당신은 GET-ChildItem을에 제외 목록을 사용할 수 있습니다

$source_listephotos = Get-ChildItem $source -Recurse -exclude $exclude_list| where {$_.FullName} 
+0

where 절은 더 이상 사용되지 않으며 RegEx 변형과 목록을 구별합니다. '$ exclude_list = @ ('Imprimerie ','otherfoler ')' – LotPings

관련 문제