Page 1 of 1

How to check for specific content of folder?

PostPosted: Thu Aug 19, 2010 4:00 pm
by opet
Hi,

I'm trying to create an action that checks the content of folders, and if it contains more than 4 files of a specific filetype/extension, then move the parent folder.

I tried to do it with a "If kind is folder then run applescript" and wrote a script that I thought would do it, but it throws an awful lot of errors in the console.

Anyone done this before?

Thanks!

Re: How to check for specific content of folder?

PostPosted: Fri Aug 20, 2010 7:28 am
by opet
Ok. I managed.

The solution to my problem was:

Code: Select all
tell application "Finder"
   set theFolder to theFile
   set transitFolder to alias (((path to home folder) as text) & "Music:__TRANSIT")
   set theFiles to every file of theFolder whose name extension is "mp3"
   if length of theFiles is greater than 4 then
      move theFolder to transitFolder
   end if
end tell

Re: How to check for specific content of folder?

PostPosted: Fri Aug 20, 2010 4:11 pm
by Mr_Noodle
Yes, you need to do a script for this type of thing. While I'm looking into some way to do this in the future, it's hard to encapsulate all the different things people want to do and I'm finding it hard to find a good a paradigm that would cover all the cases. Until I can figure something out, though, I think a script is the way to go.