2013-02-15 3 views
1

수백 개의 파일을 동일한 디렉토리에 복제하고 이름을 바꿔야합니다.powershell에서 특정 파일 이름으로 파일 복제 및 이름 바꾸기

모든 파일의 이름은 같습니다.

예.

Z:/Directory/123/Photo.jpg 
Z:/Directory/456/Photo.jpg 
Z:/Directory/789/Photo.jpg 

원본 파일을 유지하면서이 파일을 복제하고 새로운 이름을 지정해야합니다.

그래서 같은 디렉토리에 동일한 이름의 파일 2 개가 생깁니다.

Z:/Directory/123/Photo.jpg 
Z:/Directory/123/Image.jpg 
Z:/Directory/456/Photo.jpg 
Z:/Directory/456/Image.jpg 
Z:/Directory/789/Photo.jpg 
Z:/Directory/789/Image.jpg 

Powershell을 사용하여이 작업을 수행하고 싶습니다. 그러나 다른 모든 방법은 정상적으로 작동합니다.

도움을 주시면 감사하겠습니다.

감사

답변

0
Get-ChildItem Z:/Directory -Recurse -Include Photo.jpg | ? { !$_.PSIsContainer } | % { Copy-Item $_ (Join-Path $_.Directory Image.jpg) } 
+0

빠른 답변들 주셔서 감사합니다, 그것이 마치 마법처럼 일했다. – MK0

3
Get-ChildItem -Path Z:\Directory\*\Photo.jpg | foreach { Copy-Item $_ (Join-Path $_.Directory 'Image.jpg') } 
관련 문제