Re: Check to see if files exists and delete it.

From: Alex Ivanov (consul_at_collegeclub.com)
Date: 06/16/04


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
> > >
> > >
> > >.
> > >
>
>


Relevant Pages

  • Re: Terminating a process tree
    ... > that records the PID in a dedicated text file. ... When I needed to kill it I ... > Wayne Marrison wrote: ... >> tree, and because the command line starts off java.exe, which runs the ...
    (comp.lang.java.programmer)
  • Re: Maximizing
    ... Thanks, Wayne! ... Odds are, in the internal code of the command you found, it calls the api ...
    (microsoft.public.access.modulesdaovba)
  • Re: multiple instances of a form x 2
    ... thanks wayne, i would do that except there is no docmd.openForm command. ... You can them get that string in the opened form ... >> my main form is able to load multiple instances of the second form. ...
    (microsoft.public.access.forms)
  • Re: Delphi 8 and Delphi 5 coexist?
    ... > But some of them add themselfs to PATH, ... > So building from command line compiler is not so trivial. ... need to qualify paths to be sure to get the correct compiler. ... Wayne Niddery - Logic Fundamentals, ...
    (borland.public.delphi.non-technical)