Script to count the file ext's

Hi,

I have a folder in which i file some file ext "ide".Every day i need to check on these files count.Is there a way i can run the script and get the file count as.

No of ide's : 123 today
Every day these ide's change so need a way to get the count.This would make my work easier.I have the folder path from which it needs to count.

Regards
Sharath
LVL 11
bsharathAsked:
Who is Participating?
 
zoofanConnect With a Mentor Commented:
This will do both total and days total,  as for the remote,  share the directory that contains the files and change the path to point to it.

'===Start Copy===
Option Explicit
Dim objFSO,objStartFolder,objFolder
Dim objFile, colfiles
Dim f,d
f = 0
d = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Start at the root of the drive this script is located on or change to folder desired.
objStartFolder = ".\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
      If LCase(Right(objfile.name, 3)) = "ide" then
      f = f + 1
       If FormatDateTime(objFile.DateCreated, vbShortDate) = FormatDateTime(Now(), vbShortDate) then
          d = d + 1
       end if
      End If
Next
wscript.echo "There are a total of " & f & " ide files and " & d & " were created today"
'===Stop Copy===

zf
0
 
RazwerCommented:
im not an ace with vbs but editting this could help
http://www.source-code.biz/snippets/vbscript/1.htm
0
 
Admin4XPCommented:
Whats the Path? is it only these files in the path or are other file types stored there aswell?
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
zoofanCommented:
OPen notepad and paste the following,  save it as a vbs extenstion.  Save it in the root directory you want to check, or change the path where noted.  I added a date check as well incase the directory dosnt get cleaned out you have an accurate count for that day.

'====Start copy===
Option Explicit
Dim objFSO,objStartFolder,objFolder
Dim objFile, colfiles
Dim f
f = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Start at the root of the drive this script is located on or change to folder desired.
objStartFolder = ".\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
      If LCase(Right(objfile.name, 3)) = "vbs" AND FormatDateTime(objFile.DateCreated, vbShortDate) = FormatDateTime(Now(), vbShortDate) then
      f = f + 1
      End If
Next
wscript.echo "Today there were " & f & " ide Files created"
'===Stop Copy===


Any troubles let me know,

zf
0
 
zoofanCommented:
Oops  forgot to change the ext it was testing for.
If LCase(Right(objfile.name, 3)) = "vbs" should read If LCase(Right(objfile.name, 3)) = "ide"

for your extension

sry


zf
0
 
bsharathAuthor Commented:
I get this.

---------------------------
Windows Script Host
---------------------------
Today there were 5 ide Files created
---------------------------
OK  
---------------------------
0
 
zoofanCommented:
So its working for you?


zf
0
 
bsharathAuthor Commented:
Its showing the ide file updated today.What i want is total no of ide's
0
 
zoofanCommented:
no problem, thought you needed each day's count for that day

'====Start copy===
Option Explicit
Dim objFSO,objStartFolder,objFolder
Dim objFile, colfiles
Dim f
f = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Start at the root of the drive this script is located on or change to folder desired.
objStartFolder = ".\"
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
      If LCase(Right(objfile.name, 3)) = "ide" then
      f = f + 1
      End If
Next
wscript.echo "Today there were " & f & " ide Files created"
'===Stop Copy===



There you go.


zf
0
 
bsharathAuthor Commented:
Ok this worked.can i have both in the same script newly updated files and the total files.
Can i run this from a remote machine?
0
 
RazwerCommented:
just edit the objStartFolder = ".\" with the network path, ie: \\computername\c$\path\to\file
0
 
zoofanCommented:
So we should use an admin account to count files over the net?  hehehe
Was thinking a standard user account with read would do nicely, but it all good.

zf
0
 
zoofanCommented:
Sharath, did that do what you needed it to?

zf
0
 
RazwerCommented:
"So we should use an admin account to count files over the net?  hehehe
Was thinking a standard user account with read would do nicely, but it all good."

I actually typed the same type you posted the reply above it so i was just too late :P
and indeed standard user account is better, i just popped an example there ;)
0
 
RazwerCommented:
type == time
0
 
bsharathAuthor Commented:
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.