• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 303
  • Last Modified:

directory delete in VFP9 sp2

Hi Experts
I have a backup folder and everytime I do a backup I create new folder within backup folder and copy files to the new folder. What I like to do  is, delete the folders  that were created before certian date. (i.e delete older backup folders)
Thanks.
0
Balbirlally
Asked:
Balbirlally
1 Solution
 
Allister_ReidCommented:
Hi,
you can use the following:

fso = CREATEOBJECT("Scripting.FileSystemObject")
fso.DeleteFolder("c:\temp\test")

Replace the path "c:\temp\test" with the directory you wish to delete.


Regards
0
 
pcelbaCommented:
You have to test the folder date, at least...
LOCAL lcDir, ldDate, lnDcnt, lnI, laDirList[1], llSafety
lcDir = "D:\temp"
ldDate = DATE()-14

llSafety = SET("SAFETY") = "ON"
SET SAFETY OFF

lcDcnt = ADIR(laDirList, ADDBS(lcDir)+"*.*", "D")

FOR lnI = 1 TO lcDcnt
  
  IF INLIST(laDirList(lnI, 1), ".", "..") OR ! "D" $ laDirList(lnI, 5)
    LOOP
  ENDIF
  
  IF laDirList(lnI, 3) < ldDate
    ERASE (ADDBS(lcDir) + laDirList(lnI, 1) + "\*.*")
    RD (ADDBS(lcDir) + laDirList(lnI, 1))
  ENDIF
  
NEXT

IF llSafety
  SET SAFETY ON
ENDIF

Open in new window

0
 
BalbirlallyAuthor Commented:
it works very well.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now