Search and Destroy

Im a street walking cheetah with a heart full of napalm...Im a runaway son of the nuclear a-bomb...I am a worlds forgotten boy...The one who searches and destroys..   OK, so I am not Iggy Pop and the Stooges, but I do have a nice little one liner script that will search and destroy certain media types on file shares.  A lot of times a user will save music, movies or other types of media that should not be stored on a network file share.  Since, there are some tools lacking to restirct such things I have a nice little one liner script which I have saved in ARD admin and have as a Casper Policy that I can trigger manually via Casper Remote. Here is the code: Do note that the file path must match the path you wish to search and destory.  In my script as an example I used the full path of /Volumes/data_hd/homes/*   #!/bin/sh #search home directories and wipe out non supported data /usr/bin/find ‑x ‑E /Volumes/data_hd/homes/* ‑regex '.*\.(m[4po][34agpv]|mpeg|aac|asf|wmv)' ‑print ‑delete This basically goes through and wipes out all MP3, MP4, MPEG, AVI, ASF, WMV, etc files on a file share.  There may be a more elegant way to accomplish this and if you know this method please let me know and I will publish it here on my site.  Please replace my full file path with your own if you want the script to work.  If you limit the scope to one directory the find command works a lot more effeciently, if you have it just search the root expect delays in performance while it searches the whole drive. PLEASE - do try the script with out the -delete option first.  That will just print a list of files in terminal.  If you test it out and it works then add the -delete flag next.   Thanks.
Your rating: None Average: 4 (3 votes)