Hello all.
I have an Xserve G5 running OSX Server 10.4.8. It’s a college environment with all users login in via LDAP with home directories stored on the Xserve RAID.
We do not allow any MP3’s to be stored on the system, but of course they keep doing so. Is it possible to create a script to automatically delete all MP3 files from the RAID?
The Xserve has two internal mirrored drives that only contain the OS and LDAP database. All the home directories are on the RAID drive.
Can anybody help?
Model: Xserve G5 Dual 2.3Ghz
AppleScript: Latest
Browser: Firefox 2.0
Operating System: Mac OS X (10.4)
I do not have any experience working with networks, but some form of this script should do the trick:
set a to choose folder
tell application "Finder"
set audio_files to every file of entire contents of folder a whose kind contains "Audio"
repeat with a_file in audio_files
delete a_file
end repeat
empty trash
end tell
This requires the user to choose a folder, and then will get every file within that folder and all sub-folders that are audio files. This will include mp3, m4p, aiff, and probably others as well. It will then loop through the list and delete every one in the list and empty the trash at the end.
If you wanted to automate something like this, all you would need to do is to set a to the top folder of the system that contains all the user accounts, and schedule it to run every day (or every hour, or any other interval you want) using either a stay open application, cron, or launchd.
If you wanted to narrow the focus to just mp3 files, this would work:
set a to choose folder
tell application "Finder"
set audio_files to every file of entire contents of folder a whose name extension is "mp3"
repeat with a_file in audio_files
delete a_file
end repeat
empty trash
end tell
In fact, I just ran it (accidentally) and lost about 80 files. Well, good for me. I guess I’ll have to go to my backup drive and find the lost souls. Too bad Time Machine is unavailable as of yet…
Thankyou so much for replying. I will try this tomorrow as there is a student with the worst music collection in the world that really needs them deleting.
I will infact be doing him a favour lol.
Thanks