#183134 - 2007-12-02 05:01 AM
File listing
|
brewdude6
Hey THIS is FUN
Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
|
I've got to find files and return their paths that match a pattern. The folder and subfolders contain several million files with thousands of folders. I've started running this script several hours ago, but I don't know if this is ever going to finish. Is there a more efficient way to do this? Any help would be appreciated.
$type=Tscm0005,Cxac0005,Tsfm0033,Tsec0002,tsec0006,tsec0008,tsec0010,tscm0002,tsfm0081,tsfm0083,tsfm0084,tstm0001
For Each $reporttype in $type
$reports = dirplus("f:\reports\trans\monthold","/s /a-d /m " + $reporttype)
For Each $file in $reports
$=Writelog2('c:\admin\'+ $reporttype +'.txt',$file.name +";"+ $file.path)
Next
Next
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs. -Mark Twain
|
|
Top
|
|
|
|
#183136 - 2007-12-02 09:01 AM
Re: File listing
[Re: brewdude6]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
That is one (IMHO good) way to look at it. You could also take a DIRPlus() of everything and search in the result.
$reports = dirplus("f:\reports\trans\monthold","/s /a-d")
For Each $file in $reports
For Each $reporttype in $type
If InStr($file.Name,$reporttype)
...
|
|
Top
|
|
|
|
#183138 - 2007-12-02 09:30 AM
Re: File listing
[Re: Witto]
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
"The folder and subfolders contain several million files with thousands of folders."
Ouch.... Since DIRPlus has to crawl and look at each file, building an array as it goes... yeah it could take some time.
You might want to try a low tech method....
shell '%comspec% /c "f:\reports\trans\monthold" /s /a-d | find /i "' + $reporttype + '" > Files.txt'
If this directory structure is as big as you say it is, your files.txt file could be several megs large by time it is finished....
|
|
Top
|
|
|
|
#183140 - 2007-12-02 11:12 AM
Re: File listing
[Re: Witto]
|
NTDOC
Administrator
   
Registered: 2000-07-28
Posts: 11629
Loc: CA
|
sure it can, you just have to code it to do it.
|
|
Top
|
|
|
|
#183141 - 2007-12-02 01:29 PM
Re: File listing
[Re: NTDOC]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Or use Fso, works the same as Dir just imo it's faster.
Dim $FSO, $Path
$FSO = CreateObject("Scripting.FileSystemObject")
$Path = $FSO.GetFolder("C:\")
FindFiles($Path, "boot.ini")
Function FindFiles($Root, $sfile)
Dim $SubFolder, $file
For Each $file In $Root.Files
If $file.name = $sfile
? $file.path
Endif
Next
For Each $SubFolder In $Root.SubFolders
FindFiles($SubFolder, $sfile, $dest)
Next
EndFunction
|
|
Top
|
|
|
|
#183153 - 2007-12-02 04:39 PM
Re: File listing
[Re: brewdude6]
|
brewdude6
Hey THIS is FUN
Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
|
Is there a "dir" directive missing?
Got it. I agree with Bryce and Sealeopard, the Dirplus routine was churning for over 13 hours with no output. This method is working fine.
Shell '%comspec% /c dir "f:\reports\trans\monthold" /s /a-d | find /i "' + $reporttype + '" > e:\admin\"'+$reporttype+'".txt'
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs. -Mark Twain
|
|
Top
|
|
|
|
#183159 - 2007-12-02 08:50 PM
Re: File listing
[Re: brewdude6]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
If InStr($file.Name,Tscm0005) Or InStr($file.Name,Cxac0005) Or
InStr($file.Name,Tsfm0033) Or InStr($file.Name,Tsec0002) Or
InStr($file.Name,tsec0006) Or InStr($file.Name,tsec0008) Or
InStr($file.Name,tsec0010) Or InStr($file.Name,tscm0002) Or
InStr($file.Name,tsfm0081) Or InStr($file.Name,tsfm0083) Or
InStr($file.Name,tsfm0084) Or InStr($file.Name,tstm0001)
|
|
Top
|
|
|
|
#183161 - 2007-12-02 08:52 PM
Re: File listing
[Re: brewdude6]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
If InStr($file.Name,Tscm0005) Or InStr($file.Name,Cxac0005) Or
InStr($file.Name,Tsfm0033) Or InStr($file.Name,Tsec0002) Or
InStr($file.Name,tsec0006) Or InStr($file.Name,tsec0008) Or
InStr($file.Name,tsec0010) Or InStr($file.Name,tscm0002) Or
InStr($file.Name,tsfm0081) Or InStr($file.Name,tsfm0083) Or
InStr($file.Name,tsfm0084) Or InStr($file.Name,tstm0001)
|
|
Top
|
|
|
|
#183162 - 2007-12-02 08:54 PM
Re: File listing
[Re: brewdude6]
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
If InStr($file.Name,Tscm0005) Or InStr($file.Name,Cxac0005) Or
InStr($file.Name,Tsfm0033) Or InStr($file.Name,Tsec0002) Or
InStr($file.Name,tsec0006) Or InStr($file.Name,tsec0008) Or
InStr($file.Name,tsec0010) Or InStr($file.Name,tscm0002) Or
InStr($file.Name,tsfm0081) Or InStr($file.Name,tsfm0083) Or
InStr($file.Name,tsfm0084) Or InStr($file.Name,tstm0001)
|
|
Top
|
|
|
|
#183165 - 2007-12-02 09:02 PM
Re: File listing
[Re: Witto]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
lol you can delete 2 of them though
|
|
Top
|
|
|
|
#183171 - 2007-12-02 09:14 PM
Re: File listing
[Re: Witto]
|
Arend_
MM club member
   
Registered: 2005-01-17
Posts: 1896
Loc: Hilversum, The Netherlands
|
Too late to delete them
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 2924 anonymous users online.
|
|
|