Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to Delete Folders created prior to some date
Message
From
27/10/2005 11:11:47
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01003065
Message ID:
01062634
Views:
17
>>>>VFP6 I have code to delete all the files in a folder greater than some number of days ago. But I also want to delete the folders that were created > than some number of days ago. How to do?
>>>>
>>>>
>>>>arraynum=ADIR(aTemps,ctables)
>>>>FOR i = 1 TO arraynum
>>>>   if atemps(i,3)+20 < DATE()	&& last modified date was over 20 days ago
>>>>	   cFile=aTemps(i,1)
>>>>	   DELETE FILE (cpath+cFile)
>>>>   endif	
>>>>ENDFOR
>>>>
>>>
>>>Anybody come up with an answer for this. Just looking at my code and I have not solved this problem yet.
>>
>>Well, in the case of the folders, you will have to use (for example) rmdir instead of delete file.
>>
>>Or what is it that doesn't work?
>
>With my above code. Lets say that I want to delete folders whose last modified date was over 20 days ago. BTW - there are no subfolders and there are no readonly. For folders - Can I still use the ADIR, will the atemps still work, how do I tell a folder from a file so I can use the rmdir?

And in addition to what others said, you'd need to check
- "D"$aTemps[i,5] (if .t., it's a directory)
- inlist(aTemps[i,1], ".", "..") - it's the current directory or the parent directory, you'd need to skip those
- and you'd have to check that the directory is empty or you wouldn't be able to RmDir it. To make sure that's true, you could just recursively do the same routine on that directory first.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Reply
Map
View

Click here to load this message in the networking platform