3

Is there a simple terminal command maybe to delete all actual data, all files but leave all the directories there? Including packages (.app) as directories?

-- You don't need to read this: The reason why is on my iPod Touch, whenever I ssh to /private/var/mobile/Applications to get an icon or something to change for a theme, I have to look through every folder to find the application, since they're all in their unique identifier folders (e.g. 2C053638-26FE-42DD-A235-30FCBA59E623), its impossible to find it. So I copied the Applications folder to my desktop, so I could spotlight search for the application name in it and then the folder that its in would be the unique id folder on the iPod, so having it sorted the same I could easily find it.

3 Answers 3

10

Are you wanting to delete just the files from the current directory, or files from sub-directories too? For the latter this would work under most unix-a-like environments

find . -type f -print0 | xargs -0 rm -f

or if you know there are no files or directories with spaces in their names you can simplify a little with

find . -type f | xargs rm -f

I'm not an Apple user so I know little of the .app directories of which you speak, but you should be able to avoid touching them by adding grep between find and xargs like

find . -type f | grep -v \.app | xargs rm -f

Replace rm -f with ls or ls -l in all the above to get a list of what would be deleted instead of actually performing the delete.

5
  • mmm good ol' find | xargs
    – Roy Rico
    Oct 7, 2009 at 23:48
  • 2
    OS X has a modern enough version of find to support "find . -type f -exec rm -rf {} + " -- note the "+" instead of the "\;" after the -exec. This mimics the xargs part within find's exec Oct 8, 2009 at 3:30
  • no need for xargs or -exec at all, just use "find . -type f -delete"
    – akira
    Oct 8, 2009 at 5:26
  • I tend to stick to the trinity of find+grep+xargs, mainly out of habit. Way-back-when, in years past, you would come across versions of find that didn't support the more "advanced" options or didn't implement them the same way, though these days find is nearly always GNU's find (or something that mimics it accurately) but old habits die hard. Oct 8, 2009 at 11:06
  • I used find . -type f -delete worked great, now in get info the top folder takes up Zero kb, and app bundles are still there. Thanks!
    – mk12
    Oct 9, 2009 at 0:40
1

Find can delete as well:

$ find . -type f -exec rm {} \;

BE CAREFUL: this command means business--it delete all files starting from the current directory without asking.

2
  • 1
    "find . -type f -delete" would be THE delete command of find.
    – akira
    Oct 8, 2009 at 5:25
  • I learn something new every day. Thank you Akira.
    – Hai Vu
    Oct 9, 2009 at 6:34
0

open your terminal application

(1) cd {path of the iTouch content}

  for example:  cd /Users/Mike/Desktop/myTouch

(2) then recurse through the directories and remove content.

  find {directory} -type f | tee output

  for i in `grep -v .app output`
  do
   echo ${i}; rm ${i}
  done

for example,

find /Users/Mike/Documents/myTouch/ -type f | tee output

for file in `grep -v .app output`
do
 echo ${file}
 rm ${file}
done

You must log in to answer this question.

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