Page 1 of 1 1
Topic Options
#130669 - 2004-12-06 04:26 PM Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Does anyone have an exmaple of how to check and scan files inside a master folder to al scan and show the files in all sub folders that are within that master folder???
_________________________
www.microcyb.com

Top
#130670 - 2004-12-06 04:28 PM Re: Scanning sub folders
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
There are several UDFs posted that do that.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130671 - 2004-12-06 04:30 PM Re: Scanning sub folders
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Like this one.
Top
#130672 - 2004-12-06 04:34 PM Re: Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Ahhh excellent!
Thank you.
and also thank you Bryce Lindsay
_________________________
www.microcyb.com

Top
#130673 - 2004-12-06 06:30 PM Re: Scanning sub folders
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
glad to help!

Top
#130674 - 2004-12-06 11:09 PM Re: Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
OK I hit a snag, and maybe just maybe you can help.

The dirplus code works great, but I wanted to do based on a date range of old than X days.

Using the function SerialDate I am able to scan files based on a single folder, but how would I use both dirplus and SerialDate together to look for files and sub folder files within a date frame.
_________________________
www.microcyb.com

Top
#130675 - 2004-12-06 11:18 PM Re: Scanning sub folders
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
What specifically are you wanting to do with this data when found?

Please outline the complete picture here so that you don't recieve an incomplete solution.

For many copying/moving/mirror tasks the new version of Robocopy from the Server 2003 Tools download is quite capable.

Top
#130676 - 2004-12-06 11:28 PM Re: Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
OK here we go.
I will try to paint the picture for you as best as I can.

An example would be a folder c:\data and within that folder are other sub folders.

Within each root folder and sub folders are files. Each files has been created and uploaded to the root folder and sub folders at different dates.

The goal I was hoping to get to was to run the kix to scan first the root and look for any files that are past 15 days old to delete, and then also scan all subfolder and delete any files in the sub folder that are past 15 days old.

The date would be based off of the modified date.

Using the UDF function SerialDate($ExpD) I was able to write this script.

Code:

cls
break on
$path = 'c:\data
$file = dir($Path + '\*')

GLOBAL $X
;used for days compare check
$days=15
$line =1

while $file <> "" and @error = 0
$ft = getfiletime($path + '\' + $file)
$fs = getfilesize($path + '\' + $file)

$size = $foo +','+ $bar
$store = substr($file,12,3)
if $ft ;it's a file not a dir !
; List the files
$file_date = substr($ft,1,10)
;used for looking for older files
$result=SerialDate(@date)
$result=$result-$days
$result=SerialDate($result)
if $file_date < $result
;? '$file $file_date'
$size = GetFileKB($path + "\" + $file)
$line=$line+1
;DELETE FILES
$foo = $path + "\" + $file
; REMARKED THE DEL OUT FOR TESTING
; del $foo
? $foo +" "+$file_date
endif
endif
$file = dir()
loop
$line=$line-1



But I cannot do the subfolders and looking at the dirplus UDF only got even more confused.

Do I even need dirplus? Can I just do this to sub folders also?
_________________________
www.microcyb.com

Top
#130677 - 2004-12-06 11:57 PM Re: Scanning sub folders
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
here is a sample using 2 udf's DIRPlus() and FlipCTime()

Code:

$path = 'c:\temp'

$files = dirplus($path,"/s /a-d")

$15days = 60*60*24*15

for each $file in $files
$filedate = split($file.DateLastModified)
$filedate[0] = split($filedate[0],"/")
if flipctime($filedate[0][2] + "/" + $filedate[0][1] + "/" + $filedate[0][0],$filedate[1]) <= flipctime(@date,@time)-$15days
? $file.name + " is 15+ days old: " + $file.DateLastModified
endif
next




Top
#130678 - 2004-12-07 12:01 AM Re: Scanning sub folders
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
THere is alreaddy a UDF written that deletes files older than XX days.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#130679 - 2004-12-07 12:18 AM Re: Scanning sub folders
Chris S. Offline
MM club member
*****

Registered: 2002-03-18
Posts: 2368
Loc: Earth
You may want to look at fnGetFolderProp() - Uses FSO to retrieve folder properties as well. It can display the DateLastModified property and can be used to created child collections for SubFolders and Files.
Top
#130680 - 2004-12-07 05:49 AM Re: Scanning sub folders
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Or look at CleanDirectory() as Les mentioned.
_________________________
There are two types of vessels, submarines and targets.

Top
#130681 - 2004-12-07 05:59 AM Re: Scanning sub folders
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
Quote:

Or look at CleanDirectory() as Les mentioned.




does that do subfolders?

Top
#130682 - 2004-12-07 06:14 AM Re: Scanning sub folders
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
Yes.
Quote:


;REMARKS The function will recursively delete all matching files and empty subdirectories



_________________________
There are two types of vessels, submarines and targets.

Top
#130683 - 2004-12-07 06:59 AM Re: Scanning sub folders
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
hmm... perhaps this could use a little rewording Jens.

and empty subdirectories

Maybe it's just me, but I took it that it wouldn't work due to that wording. Now though I see what you meant.

Top
#130684 - 2004-12-07 05:37 PM Re: Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Excellent!
very excited to try all these options out.
You all are the best!
_________________________
www.microcyb.com

Top
#130685 - 2004-12-07 05:51 PM Re: Scanning sub folders
Microcyb Offline
Getting the hang of it

Registered: 2002-12-30
Posts: 95
Loc: Hell
Quote:

here is a sample using 2 udf's DIRPlus() and FlipCTime()

Code:

$path = 'c:\temp'

$files = dirplus($path,"/s /a-d")

$15days = 60*60*24*15

for each $file in $files
$filedate = split($file.DateLastModified)
$filedate[0] = split($filedate[0],"/")
if flipctime($filedate[0][2] + "/" + $filedate[0][1] + "/" + $filedate[0][0],$filedate[1]) <= flipctime(@date,@time)-$15days
? $file.name + " is 15+ days old: " + $file.DateLastModified
endif
next








That worked like a charm!
The one that uses CLEANDIRECTORY only did root folder.

But in short this has given me the direction I need.

Again you all are the best!!!
_________________________
www.microcyb.com

Top
Page 1 of 1 1


Moderator:  Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 580 anonymous users online.
Newest Members
Sir_Barrington, batdk82, StuTheCoder, M_Moore, BeeEm
17886 Registered Users

Generated in 0.072 seconds in which 0.026 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org