Re: Check to see if files exists and delete it.
From: Alex Ivanov (consul_at_collegeclub.com)
Date: 06/16/04
- Next message: LeapYr60: "Re: Code for counting commas in a text field?"
- Previous message: Katrina: "Re: Code for counting commas in a text field?"
- In reply to: Paul Overway: "Re: Check to see if files exists and delete it."
- Next in thread: Steven M. Britton: "Re: Check to see if files exists and delete it."
- Reply: Steven M. Britton: "Re: Check to see if files exists and delete it."
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 16 Jun 2004 14:18:40 -0700
As Wayne noted you can use the dir function:
if dir("c:\path\")>"" then kill "c:\path\*.*"
-- Please reply to NG only. The email address is not monitored. Alex. "Paul Overway" <paul@i.hate.spam.logico-solutions.com> wrote in message news:OoZfqU%23UEHA.3428@TK2MSFTNGP12.phx.gbl... > On Error resume next > > 'If the file doesn't exist...ignore the error > Kill "C:\somefile.txt" > > On Error Goto err_Handler > 'Resume error handling > > > -- > Paul Overway > Logico Solutions, LLC > www.logico-solutions.com > > > "Steven M. Britton" <anonymous@discussions.microsoft.com> wrote in message > news:1d6d801c453e4$18d83d10$a501280a@phx.gbl... > > Wayne: > > > > I only want to do this in VBA, I use the kill command > > however if there are no files to delete it tells me "File > > not found" and exits the sub. > > > > I guess I should further explain my problem. I have > > Access exporting .txt files via a TransferText and a > > query, once I export he .txt files I use Name so that I > > can rename them as .CSV files for other various uses. A > > problem arises when I try to rename the file and it > > already exist, because the user forgot to erase the > > previous file. > > > > Any Ideas? > > > > -Steve > > >-----Original Message----- > > >You can use the Shell command to do this from a Dos > > window. You can also use > > >the VBA Dir, Kill, ChDir, RmDir, and SetAttr commands. > > > > > >To simply delete all files in a folder use > > > > > >Kill <path>\*.* > > > > > >However, this won't remove subdirectories, open files, or > > files set as > > >Hidden, System, or Read Only. To do that, you'll have to > > use the other > > >commands. To remove subdirectories, you have to run > > through the directory > > >tree recursively. I tend to find it easiest just to put > > Deltree (from Dos 6, > > >Win9x) in the path or somewhere that I know where it is > > at and Shell to a > > >command prompt calling Deltree. You would call > > Command.com or Cmd.exe with > > >the /C switch. > > > > > >-- > > >Wayne Morgan > > >Microsoft Access MVP > > > > > > > > >"Steven M. Britton" <sbritton@nomail.com> wrote in message > > >news:1d0b601c453bf$0c4c4340$a601280a@phx.gbl... > > >> How can I check to see if there are files in a > > directory, > > >> and if the directory contains files delete all of them? > > >> > > >> -Steve > > > > > > > > >. > > > > >
- Next message: LeapYr60: "Re: Code for counting commas in a text field?"
- Previous message: Katrina: "Re: Code for counting commas in a text field?"
- In reply to: Paul Overway: "Re: Check to see if files exists and delete it."
- Next in thread: Steven M. Britton: "Re: Check to see if files exists and delete it."
- Reply: Steven M. Britton: "Re: Check to see if files exists and delete it."
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|