Page 1 of 1 1
Topic Options
#115502 - 2004-03-04 08:18 PM Help with folder cleanup
Chaguito Offline
Getting the hang of it

Registered: 2002-05-17
Posts: 53
Hello all...I looked into the cleandirectory() udf and doesn't work for what I need.

The thing is that there are folders created daily and after a certain amount of days need to be removed. If I use cleandirectory() it will do it but will also delete files from the folders that need to be kept.

This is a sample directory structure:

folder_03mar2004
folder_02mar2004
.
.
.
folder_26feb2004


How can I delete the folder named folder_26feb2004 without deleting files from the other folders????

Thanks
Thanks
_________________________
Chaguito, MCP

Top
#115503 - 2004-03-04 08:23 PM Re: Help with folder cleanup
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
asking for clarification...
so, you don't want to delete by folder or file date but the date specified in the folder name?
_________________________
!

download KiXnet

Top
#115504 - 2004-03-04 08:35 PM Re: Help with folder cleanup
Chaguito Offline
Getting the hang of it

Registered: 2002-05-17
Posts: 53
Quote:

asking for clarification...
so, you don't want to delete by folder or file date but the date specified in the folder name?




That is the plan!!!
_________________________
Chaguito, MCP

Top
#115505 - 2004-03-04 09:47 PM Re: Help with folder cleanup
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1341
Loc: NL
You have to make a script which looks to todays date and the creation date of the folders. Lets say you want to delete every folder older than one week.

There are some time UDF's. Search for it in the UDF forum...
_________________________
Co


Top
#115506 - 2004-03-04 09:53 PM Re: Help with folder cleanup
Chaguito Offline
Getting the hang of it

Registered: 2002-05-17
Posts: 53
And it is the cleandirectory() udf but it does not work for me because I could have certain files on all folders with dates older and would be deleted.

Anyways I'll do some more searching but the help is very appreciated!!!!
_________________________
Chaguito, MCP

Top
#115507 - 2004-03-04 09:59 PM Re: Help with folder cleanup
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1341
Loc: NL
Quote:

And it is the cleandirectory() udf but it does not work for me because I could have certain files on all folders with dates older and would be deleted.





No, it is not...

I meant DateTimeDiff(), DateCalc(), DateTimeMath(),DateMath(), SerialDate(), etc
_________________________
Co


Top
#115508 - 2004-03-04 10:07 PM Re: Help with folder cleanup
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1341
Loc: NL
And... You don't have to delete files and subdirectories only the folders on top like 26_februari, 27_februari, etc

Edited by Co (2004-03-04 10:19 PM)
_________________________
Co


Top
#115509 - 2004-03-04 10:22 PM Re: Help with folder cleanup
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
OK.. Here is something that I have been fumbling around with -

Requires the following UDFs:
WSHPIPE()
DATECALC()
LOGGER()
MAILER()

 CLS

BREAK ON
IF EXIST('H:\Profileremove.csv') DEL 'H:\Profileremove.csv' ENDIF
FOR EACH $i IN Split('01 03')
$loc='\\CITRIX'+$i+'\admin$$\profiles\'
$rc=WshPipe('%comspec% /c dir '+$loc+'*.*',1)
FOR EACH $line IN $rc
IF NOT instr($line, 'File Not Found')
;?$line
; -- Convert American Dates to European format
$dtchk=split(split($line)[0],'/')[2]+'/'+split(split($line)[0],'/')[0]+'/'+split(split($line)[0],'/')[1]
;?$dtchk
$name=split($line)[17]
$dt=DATECALC($dtchk,@date)
IF val($dt)>2 AND len($name)>3 AND $name<>'All Users' AND $name<>'DEFAULT'
?'Days ago: '+$dt
?$loc+$name
;SHELL '%COMSPEC% /C RD /S /Q '+chr(34)+$loc+'\'+$name+chr(34)
If @error<>$err=1 ELSE $err=0 ENDIF
$logdata='Days ago: '+$dt+','+$loc+$name+','+$err
LOGGER('H:\Profileremove.csv',$logdata+@crlf)
ENDIF
ENDIF
NEXT
NEXT
MAILER('recipient@@company.com','Profiles remove Log','Removal Log','H:\Profileremove.csv')


Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
Page 1 of 1 1


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

Who's Online
0 registered and 248 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.051 seconds in which 0.019 seconds were spent on a total of 12 queries. Zlib compression enabled.

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