[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

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
0
bsharath
Asked:
bsharath
  • 7
  • 4
  • 4
  • +1
1 Solution
 
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
 
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
zoofanCommented:
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:
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 7
  • 4
  • 4
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now