Skip to main content

Count Files By Type?

Comments

7 comments

  • Jcats
    Are you referring to your web server access logs, or actual files hosted in the server? For the latter, run this in the directory where you want to find and count the ext's, this is recursive. find . -type f -printf '%f\n' | rev | cut -f 1 -d '.' | rev | sort | uniq -c | sort -n
    0
  • ca2236
    Thanks Jcats, I apologize for not specifying, but it would be for our customers, they wouldn't/and don't have shell access. Is there either an addon/feature/etc where it would do the same thing, but a customer can do it from the cpanel interface.
    0
  • cPanelLauren
    Hi @ca2236 AwStats has the following section (example from my test domain so not a lot of traffic) 53031 And Analog Stats has: 53035 Normally the "extension" portion here would include an actual extension but in my case it's not really getting any traffic. Do these not suit your purposes, the hits would be equivalent to the count as each hit is a request of that file type. I am not aware of a standalone plugin that just does this for cPanel users. If this is something you'd like to see added to the product I would suggest opening a feature request using the link in my signature. You could also look at creating your own plugin that does something of this nature: Thanks!
    0
  • ca2236
    Hi cPanelLauren, thank you for taking the time to write the detailed message, I appreciate it. However, our client doesn't want a count of each type a file by the number of hits it gets. I think the client wants a list of each file type by number of times it occurs on the file system. For example. Let's say you have a website comprised of .php, .html, and .jpg the report would have to list an output similar to the following File Type | Number of files with this extension in public_html ----------------------------------------------------- .php | 25 .html | 6 .jpg | 12 Please let me know if you have any questions.
    0
  • cPanelLauren
    Hi @ca2236 As I stated previously this isn't something that is available currently. You could use the one-liner that was provided by @Jcats or you could develop your own plugin which does this but there's nothing native to cPanel that would do this and include it in the stats. Thanks!
    0
  • ca2236
    Thanks, We can resolve this question. I was responding to your question of "do these not suit my preferences", I missed the other statement saying that it wasn't available. I apologize. I will investigate what it will take to write my own plugin.
    0
  • cPanelLauren
    HI @ca2236 The guide I linked earlier may be useful as well as the forums here, there are quite a few folks who have done this. If you do need help please let us know in the cPanel Developers section of the forums! Thanks!
    0

Please sign in to leave a comment.