Computing.Net > Forums > Windows XP > Delete all files except

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Delete all files except

Reply to Message Icon

Name: Jack Joyce
Date: November 5, 2009 at 11:36:04 Pacific
OS: Windows XP
Subcategory: General
Tags: Batch file
Comment:

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.



Sponsored Link
Ads by Google

Response Number 1
Name: ace_omega
Date: November 5, 2009 at 11:44:29 Pacific
Reply:

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


0

Response Number 2
Name: probfixer
Date: November 5, 2009 at 11:46:37 Pacific
Reply:

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


0

Response Number 3
Name: Jack Joyce
Date: November 5, 2009 at 12:43:58 Pacific
Reply:

Hi Guys, thanks for the quick responses. Problem solved.

Many thanks. Jack.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More






Use following form to reply to current message:

Login or Register to Reply
LoginRegister


Sponsored links

Ads by Google


Results for: Delete all files except

Help, Disk Cleanup deletes all file www.computing.net/answers/windows-xp/help-disk-cleanup-deletes-all-file/144042.html

how do i delete all files. www.computing.net/answers/windows-xp/how-do-i-delete-all-files/58979.html

Delete Files Older Then x-Days v.3 www.computing.net/answers/windows-xp/delete-files-older-then-xdays-v3/174218.html