MacCentre
Форум: Mac и Mac OS X
Тема: Удалить файл без предупреждения. Как?
Страницы: 1 [2]

[Ответить]
Neo [22.08.2016 21:26] :
ТС в Finder очередное дикое неудобство нашёл, а вы его в Терминал посылаете.
Steps [22.08.2016 21:38] :
Ну, справедливости для, когда выборку делаешь на самом деле достаёт. Но я редко работаю с массивами файлов, так что и плювать слюной.
EsTaF [23.08.2016 08:16] :
скриптику сто лет в обед, но им не пользуюсь.


set frontAppPath to (path to frontmost application) as string

if the frontAppPath ends with ":Finder.app:" then
tell application "Finder"
set selectionList to get selection as list
set selectedCount to count items in selectionList

if selectedCount > 0 then
repeat with i from 1 to number of items in the selectionList
set selectedItem to item i of the selectionList
set selectedName to the name of selectedItem
set homePath to (path to home folder) as string
set trashPath to homePath & ".Trash:"
set deletePath to trashPath & selectedName & ":"

if not ((kind of selectedItem as string) is equal to "Volume") then
if (selectedItem as string) contains ".Trash" then
set posixPath to POSIX path of (selectedItem as string) as string
do shell script "rm -rf \"" & posixPath & "\""
else
try
deletePath as alias
display dialog "Error: file named \"" & selectedName & "\" already exists in the Trash."
on error
try
tell application "Finder" to delete selectedItem
do shell script "rm -rf ~/.Trash/\"" & selectedName & "\""
end try
end try
end if
end if
end repeat
end if
end tell
end if
EsTaF [23.08.2016 08:32] :
Если идея годная, то посидеть в нем можно. Кидать пути файлов под rm, экстрим не для меня. Хотя конечно можно сделать эдакую корзину из терминала. внутри бесконечный цикл выполнения определенного скрипта и все, что попадает внутрь, летит к чертям. Но это уж очень большой костыль. Выше Эйфелевой башни.

С локальными файлами проблем нет. Да.

Это чистилка корзины.
[Ответить]
[< Назад]