Page 1 of 1

Count number of files

PostPosted: Mon Jun 03, 2013 4:21 pm
by novajunior
Is there a way to count a certain number of files using its extension?

Example: If there is greater than 5 .txt files in the folder, then do something...

Re: Count number of files

PostPosted: Tue Jun 04, 2013 12:18 pm
by Mr_Noodle
Right now, you can only do a total count of files. To count specific types, you'll have to use a script.

Re: Count number of files

PostPosted: Tue Jun 04, 2013 1:21 pm
by a_freyer
This will allow you to run conditions on any file if there are "other" files of the same type. In the example below,

Code: Select all
if (all) of the following conditions are met for (the file or folder being processed):
     extension is CSV
     passes shell script (embedded script)
     ...

Do the following to the matched file or folder:
     send notification "there are 8 or more files in this folder with the extension " (extension)


Code: Select all
MAXCOUNT=8;
filename=$(basename "$1"); extension="${filename##*.}"
if [ "$(ls -1 $(dirname "$1")| grep -cE ".$extension$")" -gt "$MAXCOUNT" ]; then exit 0; else exit 1; fi

Re: Count number of files

PostPosted: Tue Jun 04, 2013 2:30 pm
by novajunior
Thanks, thats great I will try that out