Not sure how to do this.... (1 Viewer)

Mendel

Registered User.
Local time
Today, 10:11
Joined
Jan 18, 2001
Messages
34
I have code written to export some tables to an excel file in a particular subfolder. Is there a way to have code written or something that will clear out or delete any old files from that subfolder before the new tables get transfered into the subfolder? Thanks for any help.
 

Keith P

Registered User.
Local time
Today, 10:11
Joined
Oct 11, 2000
Messages
122
You could try the Kill statement, e.g.
Kill "C:\myFolder\mySubFolder\*.Txt"
to delete all txt files in the subfolder.
Hope this helps
 

Mendel

Registered User.
Local time
Today, 10:11
Joined
Jan 18, 2001
Messages
34
Hey that works great. Never knew of that command before. Now that it works it brings up another question. If I have the kill command coded to delete 10 files in a folder it will delete them just fine. However; I will have some cases where only some of the 10 files will exist in the folder and If I run the code that deletes them I get an error saying that the file doesn't exist. Is there a way to check to see if the file exists before deleting or some kind of error handling that will ignore the kill command if the file doesn't exist. Thanks for any help.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 04:11
Joined
Feb 28, 2001
Messages
27,229
Try searching help on keyword 'FileSearch' (which is an application).

It will tell you if a particular file exists.
 

Users who are viewing this thread

Top Bottom