2012-08-15 3 views
0

이 스크립트는 이전 질문에서 언급 한대로 폴더의 모든 파일에 @ 2x를 추가하지만 @ 2x를 제거하기 위해이 사과 스크립트를 만들거나 변경하는 방법은 무엇입니까?사과 스크립트를 사용하여 이미지에서 @ 2x를 제거하는 방법

set appendable to "@2x" 
set theFolder to choose folder 
tell application "Finder" 
    set theFiles to (files of entire contents of theFolder) as alias list 
    repeat with theFile in theFiles 
     set FileExtension to theFile's name extension as string 
     set FileName to theFile's name as string 
     set FileBaseName to text 1 thru ((offset of "." in FileName) - 1) of FileName 
     set theFile's name to FileBaseName & appendable & "." & FileExtension 
    end repeat 
end tell 

답변

1
tell application "Finder" 
    repeat with f in (files of entire contents of (choose folder) as alias list) 
     set n to name of f 
     set x to name extension of f 
     if n does not end with "@2x." & x then next 
     set name of f to text 1 thru (-5 - (count x)) of n & "." & x 
    end repeat 
end tell 

쉘에서 그것을 할 쉬울 것 : IFS=$'\n'; for f in $(find ~/Desktop -name '*@2x*'); do mv "$f" "${f//@2x/}"; done.

+0

굉장한, 그 트릭을했다. 나는 스크립팅이나 터미널에서 마스터가 아니므로 다시 한 번 감사드립니다! – SlickRemix

관련 문제