2014-09-28 2 views
1

이미지 세트가있는 폴더가 있고이 파일을 다른 폴더에 복사하여 동일한 이름으로 바꿔야합니다. 대상 폴더의 이미지는 하위 폴더에 있습니다.하위 폴더에있는 동일한 이름의 파일 복사 및 바꾸기

내가 할 수 있다고 생각한 것은 이미지 목록을 가져 와서 대체 할 파일로 필터링 한 다른 찾기 창으로 끌어다 놓는 것입니다. (하위 폴더 구조는 무시한 채로) osx는 ' 그 종류의 복사/대체를 허용합니다.

그래서 저는 이것을 automator/applescript로 해결하려고합니다. 하위 폴더 비트는 자동화 도구에서 나를 버리게합니다. 어떤 도움도 감사합니다.

example: 
source_folder/file_1.jpg 
source_folder/file_2.jpg 
source_folder/file_3.jpg 
etc... 

Should copy/overwrite targets: 
target_folder/subfolder_234/file_2.jpg 
target_folder/subfolder_122/file_1.jpg 
target_folder/subfolder_425/file_3.jpg 
etc... 

답변

2

이 스크립트는 각 파일 이름을, 그것은, 대상 폴더의 하위 폴더에 cp 명령 사본을 같은 이름의 파일을 검색하고 대체 소스 폴더에있는 파일을 얻을.

set sFolder to quoted form of POSIX path of (choose folder with prompt "Select the source folder") 
set tFolder to quoted form of POSIX path of (choose folder with prompt "Select the target folder") 
do shell script "find " & sFolder & " -maxdepth 1 -type f ! -name '.*' -print0 | while read -d $'\\0' f; do name=${f##*/}; find " & tFolder & " -type f -name \"$name\" -maxdepth 2 -mindepth 2 -exec cp -pf \"$f\" '{}' \\;;done" 
+0

쉘 스크립팅을 얻지는 못했지만 훌륭하게 작동했습니다. 많은 감사합니다. –

관련 문제