파일을 옮기고 기존 파일을 옮겨 놓거나, 기존 파일을 휴지통에 두는 등의 작업이 가능합니다.


0

나는 자동적으로 (사용자 개입없이) 파일을 A에서 B로 옮기고 B가 존재한다면 그것을 대체하여 B의 기존 사본을 적당한 휴지통 폴더에 넣는 것이 이상적이다.

이 작업은 쉘 스크립트에서 수행됩니다. 결국 A와 B가 있어야합니다. $VARIABLES 이렇게 :

/usr/bin/osascript <<EOT
tell application "Finder"
    move POSIX file "$SOURCE" to POSIX file “$DEST" with replacing
end tell
EOT

그러나 이 같은 변수없이 작동하도록조차 얻을 수 없습니다.

/usr/bin/osascript <<EOT
tell application "Finder"
    move POSIX file "/Users/luomat/Desktop/1.txt" to POSIX file "/Users/luomat/Desktop/2.txt" with replacing
end tell
EOT

나는 그 문법을 14058061 그러나 나는이 결과를 얻는다.

24:132: execution error: Finder got an error: AppleEvent handler failed. (-10000)

나도 들렀다. MacTech 기사 어떤 제안을 사용 replacing true 그래서 나는 시도했다.

/usr/bin/osascript <<EOT
tell application "Finder"
    move POSIX file "/Users/luomat/Desktop/1.txt" to POSIX file "/Users/luomat/Desktop/2.txt" replacing true
end tell
EOT

그러나 그것은 아직도 말한다 :

24:132: execution error: Finder got an error: AppleEvent handler failed. (-10000)

점에 유의하시기 바랍니다 stackoverflow # 12708195 나는 이것을하도록 사용자에게 촉구하지는 않지만, 아이가 말한 것처럼 '자동적으로'일어나는 것이 이상적이다.

그래서 ... 내가 뭘 잘못하고 있고 / 있거나 실종 됐어? 오류 코드 (-10000)에 대한 정보를 Google에 보내려고하면 "AppleScript가 실패했습니다"라는 뜻의 도움이됩니다.


엄밀히 말하자면 AppleScript와 닮았습니다. 가끔씩 결합 할 때 가장 쉬운 방법은 아닙니다. 쉘 스크립트로 완전히하지 않는 이유는 무엇입니까?
— l'L'l

훨씬 더 큰 쉘 스크립트의 일부가 될 것입니다. 이것은 그저 작은 조각 일뿐입니다.
— TJ Luoma

답변:


1

이 권리를 얻기 위해 좀 더 조사를해야합니다. 나는 그것의 가까운 느낌이지만, AppleScript는 여전히 그것을 좋아하지 않습니다. 어쩌면 내가 다시 한 번 기회를주기 위해 여기로 돌아올 때까지 몇 가지 아이디어를 줄 것입니다. Btw 이것은 파일 선택 대화 상자를 사용할 때 훨씬 쉬워 질 것입니다.

내 비 작동 (아직) 시도를 heres. 당신이 나에게 그렇게되지 않는다면 내일은 해결책을 끝내려고 노력하십시오.

# 1. get desktop folder
set desktopFolder to (((path to desktop from user domain) as string)) as alias


# 2.set source file
tell application "Finder" to ¬
set theFile to ((path to file "1.text" of folder (desktopFolder)) as string) as   alias


# 3.set destination file
tell application "Finder" to ¬
set theDestination to ((path to file "2.text" of folder (desktopFolder)) as string) as alias



# 4.make it happen
tell application "Finder" to move theFile to theDestination with replacing
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.