0

このスクリプトは、前の質問で述べたように機能して、フォルダ内のすべてのファイルに@ 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
4

1 に答える 1

2
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

于 2012-08-15T22:01:19.490 に答える