Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ProB4ProTools

macrumors newbie
Original poster
Mar 3, 2010
4
0
Hey All,

I'm trying to create a simple script that will go through the folders of a directory and label any folder that does not contain a .wav file. This directory has thousands of folders that should all contain .wav files but for me to double check I would have to scroll through all of them manually. I've tried putting together a script using some random google results but all I've gotten it to do is label the actual wav file, if it exists - that's not helpful at all, lol.

Thanks in advance!
 
There are other files in those folders along with the .wav so that isn't exactly going to do it, thanks though! Every folder in the directory should contain pdf, jpg, and wav files. There are thousands of folders and I want to make sure that all of them contain atleast one wav file. Having a script that applies the built in color labels to point out any problem folders is ideal. This way I can quickly scroll through the directory and locate any problems.
 
Hey All,

I'm trying to create a simple script that will go through the folders of a directory and label any folder that does not contain a .wav file. This directory has thousands of folders that should all contain .wav files but for me to double check I would have to scroll through all of them manually. I've tried putting together a script using some random google results but all I've gotten it to do is label the actual wav file, if it exists - that's not helpful at all, lol.

Do you need to label only the specific folder that's missing a .wav file, or do you need to also label its parent folder and so on up the parent-folder chain?

Would you be willing to accept a compromise, which created a special sentinel file named "no-waves-here" in folders that are missing a .wav file? That seems like something the 'find' command could do as a single command.

Then to get the list of all such folders, I'd tell Finder to find all the occurrences of "no-waves-here" and show it in a Find window (which could then be saved as a Smart Folder). You can do what you want with the folders at that point.

A shell command using 'find' to delete the "no-waves-here" sentinels would also be easy to do. Or you could trash them from the Find window.

The above all seem like things you can get Automator to do as steps in a workflow.

This breaks the problem down into a series of simpler steps that are easier to do individually. If you were going to repeat this task many times, it'd be worth doing a complete end-to-end script for. If it's single-use, then simpler steps with a little manual intervention are, well, simpler.

Also, what would you do with the labeled folders? Maybe that can be one of the simpler steps, too.
 
chown33, thx for the detailed response!

I need to label just the one specific folder that is missing the .wav file. There would be just one parent folder so there would be no need to label anything above that.

The "no-waves-here" method you described can definitely be an option but I'm fairly new to Automator and AppleScript so I'll have to play around a bit.

This process would be run on a few different archives which can add up to about 30,000 folders so an automated script would be ideal. I'd also like to run it occasionally just to do a checkup on things.

I just need those folders labeled to take a deeper look into why there is no wav file there. No deletion or move is necessary.

Thanks again for all the help!
 
I did a very limited test and this seemed to work:

Code:
tell application "Finder"
	set theFolderList to folders of (choose folder)
	repeat with fl in theFolderList
		set fileList to (every file of fl whose name extension is "wav")
		if fileList is {} then
			set label index of fl to 3
		end if
	end repeat
end tell

mt
 
mysterytramp, that script works like a charm! Thanks so much! I'm fairly new to AppleScript so I'm picking it apart figuring out exactly what each line of code is doing. Great learning experience!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.