Created
June 16, 2018 14:33
-
-
Save OKsign/d47af01f46bf6aef415a183095bef347 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set info to system info | |
set userName to short user name of info | |
set Source to "/Users/" & userName & "/Desktop" | |
set Dest to "/Users/" & userName & "/Desktop/sweep" | |
set Source2 to POSIX file Source | |
set Dest2 to POSIX file Dest | |
try | |
tell application "Finder" | |
set selection to every item of folder Source2 | |
set sel1 to the selection | |
set total to count item of folder Source2 | |
if folder Dest2 exists then | |
delay 0.2 | |
if total > 1 then | |
set fileLocked to 0 | |
repeat with i from 1 to total | |
if item i of folder Source2 is locked then | |
delay 0.2 | |
set x to 1 | |
set fileLocked to fileLocked + x | |
end if | |
end repeat | |
if fileLocked + 1 = total then | |
try | |
move every file of folder Dest2 to folder Source2 | |
delay 0.7 | |
move every item of folder Dest2 to folder Source2 | |
delay 2 | |
delete Dest2 | |
delay 1 | |
set the selection to {} | |
display notification "Done!" with title "Script 12" | |
end try | |
else | |
try | |
if fileLocked > 0 or fileLocked = 0 then | |
if fileLocked + 1 < total then | |
repeat with i from 1 to total | |
set cl to get class of (item i of sel1) -- folder, document file | |
if cl is folder then | |
if item i of sel1 is not locked then | |
set iName to get name of item i of sel1 | |
if iName is not "sweep" then | |
move item i of sel1 to folder Dest2 | |
end if | |
end if --item i of sel1 is not locked | |
end if -- cl is folder | |
if cl is not folder then | |
if item i of sel1 is not locked then | |
move item i of sel1 to folder Dest2 | |
end if -- item i of sel1 is not locked | |
end if --cl is document file | |
end repeat | |
delay 1 | |
set the selection to {} | |
display notification "Done!" with title "Script 12" | |
end if | |
end if | |
end try | |
end if -- fileLocked + 1 = total | |
end if -- total > 1 then | |
if total = 1 then | |
try | |
move every file of folder Dest2 to folder Source2 | |
delay 0.7 | |
move every item of folder Dest2 to folder Source2 | |
delay 2 | |
delete Dest2 | |
delay 1 | |
set the selection to {} | |
display notification "Done!" with title "Script 12" | |
end try | |
end if -- total = 1 | |
end if -- folder Dest2 exists | |
end tell | |
on error number -10000 -- folder 'sweep' not exists | |
tell application "Finder" | |
set selection to every item of folder Source2 | |
set sel1 to the selection | |
set total to count item of folder Source2 | |
if total > 0 then | |
make new folder at Source2 with properties {name:"sweep"} | |
delay 1 | |
repeat with i from 1 to total | |
set cl to get class of (item i of sel1) -- folder, document file | |
if cl is folder then | |
if item i of sel1 is not locked then | |
set iName to get name of item i of sel1 | |
if iName is not "sweep" then | |
move item i of sel1 to folder Dest2 | |
end if | |
end if --item i of sel1 is not locked | |
end if -- cl is folder | |
if cl is not folder then | |
if item i of sel1 is not locked then | |
move item i of sel1 to folder Dest2 | |
end if -- item i of sel1 is not locked | |
end if --cl is document file | |
end repeat | |
delay 1 | |
set the selection to {} | |
display notification "Done!" with title "Script 12" | |
end if | |
end tell | |
end try |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment