2014-05-12 2 views
1

폴더를 패키지 폴더 (확장자가 .tblk 인 폴더)로 옮깁니다.AppleScript 패키지 폴더

코드 :

tell application "Finder" 

    set theFolder to (choose folder with prompt "Choose source folder" default location (path to downloads folder)) 

    set theResources to make new folder at theFolder with properties {name:"Resources"} 

    set theContents to make new folder at theFolder with properties {name:"Contents"} 

    move theResources to theContents 

    set thePackage to make new folder at theFolder with properties {name:"package.tblk"} 

    move theContents to thePackage -- error here 

    set theConfigurations to (choose folder with prompt "Choose destination folder" default location (path to desktop folder)) 

    move thePackage to theConfigurations 

end tell 

오류 :

Finder got an error: Can’t make document file "Package.tblk" of folder "Desktop" of folder "craibuc" of folder "Users" of startup disk into type folder.

이 줄은 경우

set thePackage to make new folder at theFolder with properties {name:"package"} 
:

set thePackage to make new folder at theFolder with properties {name:"package.tblk"} 

로 변경됩니다

다음 스크립트는 예상대로 작동합니다.

이러한 유형의 폴더로 작업하는 더 좋은 방법이 있습니까?

답변

1

다른 작업이 완료된 후 패키지를 작성하는 코드를 리팩토링했습니다. 폴더 확장자가 변경된 후에 별칭을 사용하여 파일 참조를 유지함 :

tell application "Finder" 

    set theFolder to (choose folder with prompt "Choose source folder" default location (path to downloads folder)) 

    set theResources to make new folder at theFolder with properties {name:"Resources"} 

    set theContents to make new folder at theFolder with properties {name:"Contents"} 
    move theResources to theContents 

    set thePackage to make new folder at theFolder with properties {name:"Package"} 
    move theContents to thePackage 

    set thePackageAlias to thePackage as alias 
    set the name extension of thePackageAlias to "tblk" 

    set theConfigurations to (choose folder with prompt "Choose destination folder" default location (path to desktop folder)) 

    move thePackageAlias to theConfigurations 

end tell 
관련 문제