batch deleting backup files

Syed Zaeem Hosain Syed.Hosain at aeris.net
Thu Aug 30 14:53:46 PDT 2007


 > Perhaps adding a
 > master path and /s to catch the subdirectories would do the trick

Yes, works if the master path is consistent and does not cause
problems for any non-FM files below it - not likely, but you never
know!

Yet another possibility ... since the folders may be different for
different projects (but now, we are starting to gild the lily):

Add a parameter to the .BAT file and call it with the directory you
want - with no parameter, it just works in the current directory.
Still best to do it from a DOS window or a Run command line (which
works in this case, since you can specify the directory). BTW, I
continue to be leery of the /S - too uncontrolled an action!

	@echo off
	echo.
	echo Deleting the following files from the directory:
	cd %1%
	dir *.backup.* *.lck
	echo.
	del *.backup.* *.lck

Regards,

Z

Rene Stephenson wrote:
> It's been a while since I messed with .BAT, but... Perhaps adding a 
> master path and /s to catch the subdirectories would do the trick:
>  @echo off
>  echo.
>  echo Deleting the following files from the current directory:
>  cd [MainPathForFMfiles]
>  dir *.backup.* *.lck /s
>  echo.
>  del *.backup.* *.lck /s
> HTH
> Rene Stephenson
> 
> */Syed Zaeem Hosain <Syed.Hosain at aeris.net>/* wrote:
> 
>     Hi, Mike.
> 
>     Mike Wickham wrote:
>      >> Put the following into a file (named with extension .BAT):
>      >>
>      >> @echo off
>      >> echo.
>      >> echo Deleting the following files from the current directory:
>      >> dir *.backup.* *.lck
>      >> echo.
>      >> del *.backup.* *.lck
>      >>
>      >> and that will do the trick when you execute the batch program in a
>      >> DOS window or from the Run command line.
>      >
>      > Even easier, put a shortcut to the batch file on your desktop or
>      > elsewhere, and click on it to run it.
> 
>     Uh ... I think that is not gonna work too well, if you are in the wrong
>     directory (your desktop?) when you run it. In fact, I think my previous
>     advice to use the Run command line has the same problem! Oops.
> 
>     So, best to have it in a folder that is in your path and then execute it
>     from a DOS window in the correct directory.
> 
>     As, also mentioned by others for the DEL command, if you want all backup
>     files in a directory tree removed, you can add the /S switch. What was
>     not mentioned is that you can add that switch to the DIR command too!
> 
>     BTW, I would be very careful of the /S switch ... if you are in the
>     wrong
>     folder. When I tried it from my C:\ root, it found some files that I
>     would
>     not want deleted (without knowing what they were)!
> 
>     Z



More information about the framers mailing list