휴지통에있는 모든 것을 자동으로 되돌릴 수있는 방법이 있습니까? 모든 것을 되돌릴

아내는 Finder에서 ‘모든 문서’폴더를보고 휴지통으로 옮기기로 결정했습니다.

이제 휴지통에 9,000 개가 넘는 파일이 있으며 한 번의 클릭으로 모든 것을 되돌릴 수있는 방법을 찾지 못했습니다.

어떤 이유로 한 번에 하나의 파일 만 ‘다시 되돌릴’수 있습니다.

이것을 자동화하는 방법이 있습니까?



답변

다중 항목 선택에 대해 “뒤로 반입”이 비활성화 된 경우, 선택된 항목 중 하나 이상에 휴지통 위치의 .DS_Store 파일에 저장된 원래 위치 정보가없는 것입니다.

이상적이지는 않지만 나머지 파일을 수동으로 제출하기 전에 일괄 적으로 “뒤로”배치 할 수있는 그룹을 찾는 파일의 다중 선택 하위 집합을 사용해보십시오 .


답변

AppleScript 편집기에서 다음과 같은 스크립트를 실행하십시오.

repeat
    tell application "Finder"
        close windows
        if items of trash is {} then return
        open trash
        activate
    end tell
    tell application "System Events"
        key code 125 -- down arrow
        key code 51 using command down -- command-delete
    end tell
end repeat

일부 항목을 다시 넣으려고 할 때 Finder에 비밀번호 대화 상자가 표시되면 tell application "System Events"블록 끝에 다음과 같이 추가하십시오 .

delay 1
if exists window 1 of process "SecurityAgent" then
    tell window 1 of process "SecurityAgent"
        set value of text field 2 of scroll area 1 of group 1 to "pa55word"
        click button 2 of group 2
    end tell
end if
delay 1


답변

“휴지통의 모든 항목을 다시 넣습니다”라는 AppleScript가 저에게 효과적 이었습니다.

“AppleScript Editor”를 열고 아래 행을 복사 / 붙여 넣기 한 다음 필요한만큼 스크립트를 실행하십시오.

tell application "System Events"
    tell process "Finder"
        repeat 100 times
            tell application "Finder" to open trash
            tell application "Finder" to activate
            key code 126
            key down command
            key code 51
            key up command
            delay 0.2 -- adjust delay as needed
        end repeat
    end tell
end tell
tell application "Finder" to close every window


답변

이 AppleScript 코드는 최신 버전의 macOS Mojave를 사용하여 작동합니다.

이 코드는 휴지통에있는 모든 항목을 반복하여 각 항목을 원래 위치로 되돌립니다.

휴지통에있는 파일의 원본 소스 폴더가 더 이상 존재하지 않으면 repeat until trashCount is 0명령이 루프를 종료합니다. 휴지통에 남아있는 파일은이 이유로 인해 되돌릴 수없는 파일 만됩니다.

최신 정보

휴지통에서 파일을 다시 가져 오는 프로세스의 반복 루프 중에 데스크탑에서 항목을 선택할 수 있으므로 선택한 데스크탑 항목이 프로세스에 걸리고 휴지통으로 이동 될 수 있습니다. 이 시나리오를 피하기 위해 현재 잠금 해제 된 데스크탑 항목을 잠그고 스크립트 끝에서 잠금을 해제하는 코드를 추가했습니다.

이제 모든 데스크탑 항목이 잠겨 있기 때문에 … 휴지통에서 파일을 되 돌리는 과정에서 어떤 이유로 든 실수로 데스크탑에서 파일 또는 폴더를 선택하고 코드가 선택된 데스크탑 항목을 처리하려고 시도하는 경우 … 항목이 잠겨 있음을 나타내는 대화 상자 창을 생성하고 휴지통으로 계속 보낼 것인지 묻습니다. 스크립트 끝까지 시스템 이벤트 텔 블록은 생성 된 대화 상자를 처리합니다.

property desktopFolder : path to desktop
property unlockedFiles : missing value

tell application "Finder"
    set trashCount to count of every item of trash
    set unlockedFiles to (items of desktopFolder whose locked is false)
    repeat with i in unlockedFiles
        set locked of i to true
    end repeat
end tell

repeat until trashCount is 0
    tell application "Finder" to set orphanCount to count of every item of trash
    putFilesBack()
    tell application "Finder" to set trashCount to count of every item of trash
    if orphanCount is equal to trashCount then exit repeat
end repeat

delay 1

tell application "System Events"
    repeat until not (exists of button "Stop" of scroll area 1 of window 2 of application process "Finder")
        if exists of button "Stop" of scroll area 1 of window 2 of application process "Finder" then
            click button "Stop" of scroll area 1 of window 2 of application process "Finder"
        end if
    end repeat
end tell

tell application "Finder"
    close every Finder window
    delay 1
    repeat with i in unlockedFiles
        set locked of i to false
    end repeat
end tell

on putFilesBack()
    global trashFiles, trashCount, thisItem
    tell application "Finder"
        set trashFiles to every item of trash
        set frontmost to true
        repeat while not frontmost
            delay 0.1
        end repeat
        my closeFinderWindows()
    end tell
    delay 0.1
    tell application "System Events"
        tell application process "Finder"
            repeat with i from 1 to count of trashFiles
                set thisItem to item i of trashFiles
                delay 0.1
                set frontmost to true
                select thisItem
                delay 0.1
                try
                    key code 51 using {command down}
                end try
                delay 0.1
                my closeFinderWindows()
                delay 0.1
            end repeat
        end tell
    end tell
    tell application "Finder" to set trashCount to count of every item of trash
end putFilesBack

on closeFinderWindows()
    tell application "Finder"
        set finderWindowRef to (a reference to (every Finder window whose name is not "Trash"))
        set finderWindowRef to contents of finderWindowRef
        close (items of finderWindowRef)
    end tell
end closeFinderWindows


답변

모든 파일을 강조 표시하거나 최소한 증분 배치로 파일을 복사 한 다음 복사 한 후 다시 붙여 넣어야합니다. 방금 시도한 결과 휴지통을 두 번 클릭하면 복원 할 파일을 마우스 오른쪽 버튼으로 클릭하면 복원 할 파일을 마우스 오른쪽 버튼으로 클릭 할 수 있습니다. 파일로만 작동하는 “뒤로 되돌리기”옵션이 있습니다. 그런 다음 Cv (명령 v)를 사용하여 다시 붙여 넣습니다.


답변

이것은 나를 위해 일했다 :

  • Finder에서 새 폴더를 만듭니다. “내 파일을 복구했습니다”라고했습니다.
  • 휴지통 폴더를 열고 파일 그룹을 선택하십시오.
  • 파일을 복사하여 “복구 된 파일”폴더에 붙여 넣습니다.

큰 폴더 또는 많은 수의 개별 파일을 되돌려 야하는 경우이 기술을 사용하십시오. 하나 또는 두 개의 파일 만 필요한 경우 “뒤로 되돌리기”기능을 사용하십시오.


답변

Snow Leopard 이전에는 OS X에 기본적으로 파일이 삭제 된 원래 위치로 파일을 복원 할 수있는 기능이 없었습니다 (Windows 환경에서 휴지통 컨텍스트 메뉴의 “복원”옵션을 사용하여 기본적으로 수행 할 수 있음). 우연히 부인이 한 곳에서 약 10,000 개의 더하기 파일을 삭제 한 것과 똑같은 일을했습니다.

모든 옵션을 살펴본 후 Time Machine을 통해 시스템 복원을 수행했습니다. 파일을 적절한 위치로 가져 오는 것이 가장 편리한 방법이었습니다.