Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hi
Can anyone help me with an if statment in a batch file. Basically I have a number of Excel files in the Excel Start Folder. One file named PERSONAL.XLS I need to keep. All the other .xls files I need to delete.
If I use:
DEL "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\*.xls"
then all the files including PERSONAL.XLS are deleted. Any help with some code to delete the files and keep PERSONAL.XLS would be great.

Quick and dirty way...
@Echo off Copy "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\PERSONAL.XLS" "C:\Documents and Settings\%username%\Application Data\Microsoft\" DEL "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\*.xls" Copy "C:\Documents and Settings\%username%\Application Data\Microsoft\PERSONAL.XLS" "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\" DEL "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\PERSONAL.XLS"
Ooops yes, here you go..

I have got a good idea:
FileCopy "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\personal.xls","C:\personal.xls"
DEL "C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\*.xls"FileCopy "C:\presonal.xls","C:\Documents and Settings\%username%\Application Data\Microsoft\Excel\XLSTART\personal.xls"
DEL "C:\Personal.xls"
..me and the previous poster have similar opinions, but he forgot to clean up...

![]() |
![]() |
![]() |
| Login or Register to Reply | |
| Login | Register |
| Ads by Google |