2012-11-16 3 views
2

나는 매일 내 사이트에서 다운로드 한 파일을 기반으로 나를 위해 함수를 실행하는 스크립트를 만들려고합니다.AppleScript로 변수가있는 폴더 열기

기본적으로 내 사이트는 날짜 (yyyy, mm, dd)를 기준으로 폴더를 만듭니다. 먼저 해당 폴더를 열려면 applescript를 누른 다음 내부의 각 폴더/파일에 대한 작업을 실행합니다.

문제는 변수를 사용하여 스크립트를 해당 폴더로 지정하려고하면 오류가 발생합니다. 경로 이름을 상수로 만들 수 없습니다.

어쩌면 실제 문제는 내가이 새로운 방법입니다! 다음은 내가 시도한 내용입니다.

tell application "Finder" 
    set {year:y, month:m, day:d} to (current date) 
    set theTime to y & m & d 
    set pathToTarget to path to theTime 
    open folder pathToTarget of folder "F-grams" of folder "files" of folder "default" of folder "sites" of folder "foldagram" of folder "htdocs" of folder "MAMP" of folder "Applications" of startup disk 
end tell 

누가 초보자를 도우려고합니까? -JB

+0

: 당신이 날짜별로 폴더를 검색하기를 원한다면

on adding folder items to theFolder after receiving theFolders try repeat with aFolder in theFolders tell application "Finder" to set myItems to every item of aFolder repeat with anItem in myItems -- Insert your code here end repeat end repeat on error errMsg number errNum tell me activate display alert errMsg & return & return & "Error number" & errNum buttons "Cancel" end tell end try end adding folder items to 

그러나, 이것은 당신이 날짜 문자열을 포맷하는 방법이다 "theTime의 경로에 pathToTarget 설정"- - –

답변

1

이 폴더 작업은 새 항목이 대상 폴더에 추가 될 때마다 트리거됩니다. 두 번째 반복 블록을 사용하면 추가 된 각 폴더에서 각 항목에 대한 명령을 보낼 수 있습니다. anItem 변수를 사용하여 이러한 각 항목을 참조 할 수 있습니다. 라이브러리의 폴더 작업 스크립트 폴더에 스크립트를 저장하십시오. 폴더 작업을 대상 폴더에 첨부하십시오. 이 줄은 오류를 생성

set delimiter to ", " 
set aDate to (current date) 
set aYear to (year of aDate) as string 
set aMonth to (month of aDate as integer) as string 
if length of aMonth is 1 then set aMonth to "0" & aMonth 
set aDay to (day of aDate as integer) as string 
if length of aDay is 1 then set aDay to "0" & aDay 
set theTime to aYear & delimiter & aMonth & delimiter & aDay as string 
관련 문제