Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set thePaths to {"path/to/scan/for/files1", "path/to/scan/for/files2/etc"}
- set theProgramName to "File Counter"
- set theProgramWarningMessageUponFindingFilesThatExceedUpperLimit to "Hey there, fellow student, I see there you have some dandy files knocking around your Desktop and stuff. I'm pretty sure I told you about that thing we have, ownCloud? Yeah, use that man!"
- set theMaxAmountOfFilesAndFolders to 1
- ----------------------------------------------------------------------------------
- ------------ DON'T EDIT THIS BELOW UNLESS YOU KNOW WHAT YOU'RE DOING ------------- -- Thomas Jones (08/02/16)
- ----------------------------------------------------------------------------------
- set counter to 0
- set warn to false
- repeat (count thePaths) times
- set counter to (counter + 1)
- set thePath to item counter of thePaths as string
- set theCount to (do shell script "ls -l \"" & thePath & "\" | wc -l | awk '{ print $1 }'") as integer
- set theCount to (theCount - 1) # we do this to remove possible hidden files like Desktop_DF etc
- if theCount is greater than theMaxAmountOfFilesAndFolders then
- set warn to true
- end if
- end repeat
- if warn is true then
- display alert theProgramName message theProgramWarningMessageUponFindingFilesThatExceedUpperLimit as warning
- do shell script "date >> ~/.userWasWarnedAboutHighAmountOfLocalFiles"
- end if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement