4

I am trying to delete a hidden file that shows up every time I restart my computer with an Apple Script set to run on startup. I can't however seem to be able to correctly guess the path of this file.

The file's path is Macintosh HD/Users/cristian/Dropbox (Hyperion)/Hyperion Team Folder/Icon

If I move the file to the desktop and run the script bellow, it works.

tell application "Finder"
    delete the file "Icon
" of the desktop
end tell

My question is, how do I change this script to target the path above? Also, is there anyway to permanently delete it not just move it to the trash?

Thanks in advance.

1
  • You say you can't correctly guess the location, then you tell us the location... ? Commented Nov 15, 2015 at 8:04

2 Answers 2

5

Assuming there is no new line character at the end of the file name this code deletes the file in the Dropbox folder and empties the trash.

Be aware that the empty trash command affects all items in the trash not only the currently deleted file.

set iconFile to ((path to home folder as text) & "Dropbox (Hyperion):Hyperion Team Folder:Icon"
tell application "Finder"
    delete file iconFile
    empty trash
end tell

Alternatively use the shell to delete the file, in this case the file will be deleted immediately.

set iconFile to POSIX path of (path to home folder) & "Dropbox (Hyperion)/Hyperion Team Folder/Icon"
do shell script "/bin/rm " & quoted form of iconFile
Sign up to request clarification or add additional context in comments.

Comments

2

just use a do shell script command "rm" which delete file directly (without transfer to trash), like in script bellow :

Set myFile to "Macintosh HD/Users/cristian/Dropbox (Hyperion)/Hyperion Team Folder/Icon"
try
do shell script "rm " & quoted form of myFile
end try

However, it should be better to understand root cause why this file is added every time, and then address this root cause.

1 Comment

This is not AppleScript deleting the file, rather a shell script. It also spawns yet another process (the shell) to do this

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.