Page 1 of 1
Counting Files In A folder
Posted: Sun Sep 21, 2008 5:43 am
by warrenk
I am trying to count the number of files in a selected folder and place it in a text box. I am a newbie so I do apologize if this is something very basic. I have searched the documentation and couldn't find any help for this.
Thanks for any help!
Warren
Posted: Sun Sep 21, 2008 8:14 am
by Garrett
If these are in the Media version, then check out the following in the documents:
defaultfolder
files
defaultfolder will allow you to select the directory you need and you can use that also when using files to get a list of all the files in the directory you set with defaultfolder.
Posted: Sun Sep 21, 2008 12:48 pm
by bn
hi warrenk,
try this, it should get you started
Code: Select all
on mouseUp pMouseBtnNo
answer folder "please choose folder to get the files of"
if it is empty then exit mouseUp
put it into tFolderToSearch
put the defaultfolder into tOldDefaultFolder -- to restore it later
set the defaultfolder to tFolderToSearch
put the files into tAllFiles -- gives you all the files of the folder
-- you may want to filter the files for the type you want; look up filter with or filter without
--filter tAllFiles without ".*" -- on a mac there are invisible files that start with a dot
--filter tAllFiles with "*.rev" -- to just get rev stacks
--filter tAllFiles with "*.pdf" -- to just get pdfs
set the defaultfolder to tOldDefaultFolder -- restore the default folder, not necessary but nice
put 0 into tSoMany -- just in case there are none
put the number of lines of tAllFiles into tSoMany
put "there are " & tSoMany & " files" & return & "these are the files: " & return & tAllFiles
end mouseUp
regards
bernd
Posted: Sun Sep 21, 2008 4:54 pm
by warrenk
Thanks Bernd...thats exactly what I was looking for!
Much appreciately!!!!
Warren