Looking to tidy up my iMac.

Like everyone, I have lots of files/folders on my iMac. When they get dragged and dropped, or moved around, they retain their position, and the only way to fix this is to right click on the mouse select 'Clean up By' > 'Name'

I'm wanting to run a script in Terminal (or similar) that will do this to every file/folder on my iMac

E.g. Directory X contains four files

ABC99, ABC45, ABC32, ABC01

After running the script, the folder should contain the same files but in the correct order

ABC01, ABC32, ABC45, ABC99

  • ah, got it, you want to automatically run "Clean up -> by name" for every folder in Finder. Hmm, might require an Applescript solution...
    – nohillside
    Commented May 20, 2015 at 11:41
  • Sounds good to me, any ideas? Commented May 20, 2015 at 13:18

2 Answers 2


Deleting .DS_Store SHOULD reset the appearance of a folder's content.

BTW, the problem with the other answer could be the handling of special characters, which in my guess is space.

For example, you have a home directory named "First Last". In find, the result it pipes out would be:

/Users/First Last/.DS_Store

etc. Try,

rm /Users/First Last/.DS_Store

would end in error, because the two properly escaped forms are:

rm  /Users/First\ Last/.DS_Store


rm "/Users/First Last/.DS_Store"

The correct way to go about it should be: run

find / -name ".DS_Store"

first to list all .DS_Store files. (Don't mind the Permission Denied.) Then

find / -name ".DS_Store" -delete

to delete all that you saw. Then

find / -name ".DS_Store"

again to confirm.

sudo is excessive. Unless you have used "sudo open -a Finder; killall Finder" before. A user's Finder has not have permission necessary to create .DS_Store files in /Library, /System, etc.


To clean up your entire hard drive (starting from mount point /), you can use:

$ sudo find / "-name" ".DS_Store" -exec rm {} \;
  • Thanks, but I already use that command to remove all the .DS_Store files. I'm trying to clean-up the files in all the folders on my hard drive. Commented May 20, 2015 at 11:23
  • Which files do you want to remove/clean up now? You could use the said command to remove them as well.
    – frdmn
    Commented May 20, 2015 at 11:24
  • By clean up, I mean to arrange in order of name. Commented May 20, 2015 at 11:24
  • @DavePearce What app are you wanting to see the files in order in? If you remove the .DS_Store file doesn't the finder show then in order? If not what order does it show them in?
    – mmmmmm
    Commented May 20, 2015 at 11:47
  • @Mark When I remove the .DS_Store file, the folders appear to retain their positions and no change is made. Commented May 20, 2015 at 13:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .