Indigo Rose Software
  #1  
Old 10-09-2005
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,058
Post Function: File Count in a Directory

-- This funciton will allow for the counting of all files in a directory (aka. folder)
function f_FileCount(dir)
tblFiles = File.Find(dir, "*.*", true, false, nil, nil)
if tblFiles ~= nil then
for i,v in tblFiles do
count = i
end
-- This is just one way to display the results
Dialog.Message("Directory file count...", "There are "..count.." files in that directory")
else
Dialog.Message("Directory file count...", "There are 0 files in that directory")
end
end

-- Example on how to use this function (also known as a "function call")
f_FileCount("AutoPlay\\Docs")
__________________
Intrigued
www.amsuser.com
Reply With Quote
  #2  
Old 08-23-2006
gogubooman gogubooman is offline
Forum Member
 
Join Date: Sep 2005
Posts: 3
Large folder

If the folder has waay to many files....the response of the function will be slow...

My snippets folder...has around 13.300 files it took ~10 seconds to produce the result
Reply With Quote
  #3  
Old 09-10-2006
RizlaUK's Avatar
RizlaUK RizlaUK is offline
Forum Member
 
Join Date: May 2006
Location: London UK
Posts: 3,129
nice function, right about the time on large dir, i just added a status dialog to it so it dosent give the hanging effect

eg:
Code:
StatusDlg.Show(MB_ICONNONE, false);
-- Example on how to use this function (also known as a "function call")
f_FileCount("C:\\")
StatusDlg.Hide();
scaned my whole c drive in 20 seconds, while displaying all files scaned
Reply With Quote
  #4  
Old 09-10-2006
Intrigued's Avatar
Intrigued Intrigued is offline
Indigo Rose Customer
 
Join Date: Dec 2003
Location: Location! Location!
Posts: 6,058
Another version with a Cancel button this time:

Code:
-- This funciton will allow for the counting of all files in a directory (aka. folder)
function f_FileCount(dir)
	StatusDlg.Show(MB_ICONNONE, false);
	StatusDlg.ShowCancelButton(true, "Cancel")
		tblFiles = File.Find(dir, "*.*", true, false, nil, nil)
			if tblFiles ~= nil then
				for i,v in tblFiles do
					blnIsCancelled = StatusDlg.IsCancelled()
						if blnIsCancelled ~= true then 
							count = i
						else
							blnQuit = true
								break
						end				
				end
					StatusDlg.Hide()
					
					if blnQuit ~= true then
						-- This is just one way to display the results
						Dialog.Message("Directory file count...", "There are "..count.." files in that directory")
			end
							blnQuit = false
					end
end

-- Example on how to use this function (also known as a "function call")
f_FileCount("C:\\")
__________________
Intrigued
www.amsuser.com
Reply With Quote
  #5  
Old 10-12-2006
Stefan_M's Avatar
Stefan_M Stefan_M is offline
Indigo Rose Customer
 
Join Date: Nov 2003
Location: Salzburg / Austria
Posts: 295
Another version with "Table.count" instead of a loop

function f_FileCount(dir)
local count=0;
tblFiles = File.Find(dir, "*.*", true, false, nil, nil)
if tblFiles ~= nil then
count = Table.count(tblFiles);
end;
return count;
end;

usage:
number_of_files=f_FileCount("C:\")


Stefan_M
__________________
"With a rubber duck, one's never alone."

Douglas Adams, The Hitchhiker's Guide to the Galaxy
Reply With Quote
  #6  
Old 11-29-2006
latell latell is offline
Forum Member
 
Join Date: Nov 2006
Posts: 1
Peekaboo! Hi!

Hi

Just made this one today.

it's a file list counter
put the whole path into the Directory Tab
and pressing Commence or Enter will do.

http://mfiles.naver.net/69bb5f8992c3...6-terratan.exe

Last edited by latell; 11-29-2006 at 02:17 AM.
Reply With Quote
  #7  
Old 10-02-2007
spider spider is offline
Forum Member
 
Join Date: Aug 2007
Posts: 13
excuse me
can the files be arranged with filename ,or by CreationDate,or by WriteDate?
can some body give some ideas or example
Reply With Quote
  #8  
Old 10-06-2007
arb's Avatar
arb arb is offline
Indigo Rose Customer
 
Join Date: Jul 2007
Posts: 122
Quote:
Originally Posted by spider View Post
excuse me
can the files be arranged with filename ,or by CreationDate,or by WriteDate?
can some body give some ideas or example
You can use File.GetAttributes and .CreationDateISO in loop then remove "-" from result of date and sync. each file with other.
Reply With Quote
  #9  
Old 10-14-2007
RizlaUK's Avatar
RizlaUK RizlaUK is offline
Forum Member
 
Join Date: May 2006
Location: London UK
Posts: 3,129
Quote:
You can use File.GetAttributes and .CreationDateISO in loop then remove "-" from result of date and sync. each file with other.
yup, used with "Table.Sort" should do the trick
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://yourfilelink.com - 50MB max upload, free! Intrigued General Chat 14 09-26-2006 09:44 AM
help with ftp connect CAI AutoPlay Media Studio 6.0 0 09-29-2005 08:13 PM
HOWTO: Create a Project Template Support AutoPlay Media Studio 4.0 Examples 0 10-28-2002 02:49 PM
Can search allow manual browse even if file is found? RichardShaw Setup Factory 5.0 2 08-28-2000 07:08 PM
Install only into one of several directories with specific existing file? RichardShaw Setup Factory 5.0 0 08-17-2000 03:29 PM


All times are GMT -6. The time now is 08:28 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright © 2000 - 2009 Indigo Rose Corporation. All rights reserved.
Indigo Rose Software