 |
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.
|
03-22-2011
|
#1 | | Windows 7 Home Premium x64 SP 1 |
Batch file I've created a batch file I use to remove some backup files (.bak) that seem stubborn to leave. However, and this is on an XP laptop, not Windows 7, I've discovered that there is a critical data.bak file that must remain (again, XP, not Windows 7) so that MS Office XP will work. When the file is deleted, Office programs will not start without reinstalling "the component."
So is there a switch or separate command I can use with the line "del c:\*.bak /s" that would delete all *.bak files except this one: c:\documents and settings\all users\application data\microsoft\office\data\data.bak?
Thanks.
| My System Specs | | System Manufacturer/Model Number Dell Studio XPS 8100 OS Windows 7 Home Premium x64 SP 1 CPU Intel Core i7 860 @ 2.8 GHz Motherboard Dell 0T568R (CPU1) Memory 8.0 GB Dual Channel DDR3 @ 664 MHz (9-9-9-24) Graphics Card nVidia GeForce GTS 240 Sound Card M-Audio Delta Audiophile 2496 Monitor(s) Displays Dell 2407WFP Screen Resolution 1920x1200 Hard Drives 977 GB Western Digital WDC WD1001FAES-75W7A0 (SCSI) Other Info Microsoft Security Essentials, Mozilla Firefox, Mozilla Thunderbird. M-Audio Keystation 88es (keyboard controller), Western Digital Passport 250 GB external HD, Logitech Z2300 speaker system, two Mushkin Enhanced Mulholland 16GB USB flash drives, AKG K240 Studio headphones. |
03-23-2011
|
#2 | | Windows 7 Ultimate x64 Service Pack 1 |
The del command doesn't have a switch in particular to achieve what you wish and since they are all ending with the bak extension, wildcards won't be of much help.
I don't know if it's helpful but maybe if you can set the file to have a certain attirbute, you can exclude it. There is a switch to the del command that will exclude the file based on it's attribute. Here's the complete listing of switches thanks to the del /? command. Code: DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names
names Specifies a list of one or more files or directories.
Wildcards may be used to delete multiple files. If a
directory is specified, all files within the directory
will be deleted.
/P Prompts for confirmation before deleting each file.
/F Force deleting of read-only files.
/S Delete specified files from all subdirectories.
/Q Quiet mode, do not ask if ok to delete on global wildcard
/A Selects files to delete based on attributes
attributes R Read-only files S System files
H Hidden files A Files ready for archiving
- Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows:
The display semantics of the /S switch are reversed in that it shows
you only the files that are deleted, not the ones it could not find. | My System Specs | | System Manufacturer/Model Number Custom Built OS Windows 7 Ultimate x64 Service Pack 1 CPU AMD Athlon II x4 Propus 2.9 GHz Motherboard ASUS M2N68 AM-PLUS Memory Transcend 2 x 2 GB DDR2800 Graphics Card Sapphire Radeon HD 5670 1GB GDDR5 Sound Card On-board 6-Channel HD Audio, Split Audio via 3.5mm Splitter Monitor(s) Displays 22' Chimei 22QD Screen Resolution 1920 x 1080 Keyboard A4tech KL-126 Backlit Keyboard Mouse A4tech N400 Padless Mouse PSU Generic 600W Case Generic Transparent Side Cooling Generic 2 x 80mm Fans Hard Drives 1 x 80 GB SATA 7200 RPM
1 x 500 GB SATA 7200 RPM
1 x 1 TB Western Digital MyBook Essentials Internet Speed 1Mb/s DL, 0.9Mb/s UL Other Info Altec Lansing BXR 1221
Sennheiser HD201
ZTE Modem
Linksys WRT-54GH
Nokia C7-00 Hacked
Nokia E5-00 Hacked
Samsung ES65
1 X 4GB Bootable USB
1 X 2GB USB Flash Drive
1 X 2GB microSD Storage |
03-23-2011
|
#3 | | |
Hi,
You could add a couple of extra lines to your batch file that will rename the file, perform the delete then rename again Code: c:
cd "documents and settings\all users\application data\microsoft\office\data"
ren data.bak data.new
cd\
[insert delete code here]
c:
cd "documents and settings\all users\application data\microsoft\office\data"
ren data.new data.bak
cd\ It should then rename the file both before and after the delete script, keeping it intact.
OS | My System Specs | | System Manufacturer/Model Number Compaq Desktop OS Windows 7 Ultimate x64 CPU AMD Sempron Dual Core Memory 3GB Graphics Card NVIDIA GeForce 6150SE nForce 430 Screen Resolution 1024x768 Hard Drives 150GB Sata |
03-23-2011
|
#4 | | Windows 7 Ultimate x64 Service Pack 1 |

Quote: Originally Posted by Orbital Shark Hi,
You could add a couple of extra lines to your batch file that will rename the file, perform the delete then rename again Code: c:
cd "documents and settings\all users\application data\microsoft\office\data"
ren data.bak data.new
cd\
[insert delete code here]
c:
cd "documents and settings\all users\application data\microsoft\office\data"
ren data.new data.bak
cd\ It should then rename the file both before and after the delete script, keeping it intact.
OS That's an even better suggestion! I didn't think of that. | My System Specs | | System Manufacturer/Model Number Custom Built OS Windows 7 Ultimate x64 Service Pack 1 CPU AMD Athlon II x4 Propus 2.9 GHz Motherboard ASUS M2N68 AM-PLUS Memory Transcend 2 x 2 GB DDR2800 Graphics Card Sapphire Radeon HD 5670 1GB GDDR5 Sound Card On-board 6-Channel HD Audio, Split Audio via 3.5mm Splitter Monitor(s) Displays 22' Chimei 22QD Screen Resolution 1920 x 1080 Keyboard A4tech KL-126 Backlit Keyboard Mouse A4tech N400 Padless Mouse PSU Generic 600W Case Generic Transparent Side Cooling Generic 2 x 80mm Fans Hard Drives 1 x 80 GB SATA 7200 RPM
1 x 500 GB SATA 7200 RPM
1 x 1 TB Western Digital MyBook Essentials Internet Speed 1Mb/s DL, 0.9Mb/s UL Other Info Altec Lansing BXR 1221
Sennheiser HD201
ZTE Modem
Linksys WRT-54GH
Nokia C7-00 Hacked
Nokia E5-00 Hacked
Samsung ES65
1 X 4GB Bootable USB
1 X 2GB USB Flash Drive
1 X 2GB microSD Storage |
03-23-2011
|
#5 | | Windows 7 Home Premium x64 SP 1 |
OK, OS. Great idea. I'll try that. Thanks.
And thanks oreo27. That might also work. | My System Specs | | System Manufacturer/Model Number Dell Studio XPS 8100 OS Windows 7 Home Premium x64 SP 1 CPU Intel Core i7 860 @ 2.8 GHz Motherboard Dell 0T568R (CPU1) Memory 8.0 GB Dual Channel DDR3 @ 664 MHz (9-9-9-24) Graphics Card nVidia GeForce GTS 240 Sound Card M-Audio Delta Audiophile 2496 Monitor(s) Displays Dell 2407WFP Screen Resolution 1920x1200 Hard Drives 977 GB Western Digital WDC WD1001FAES-75W7A0 (SCSI) Other Info Microsoft Security Essentials, Mozilla Firefox, Mozilla Thunderbird. M-Audio Keystation 88es (keyboard controller), Western Digital Passport 250 GB external HD, Logitech Z2300 speaker system, two Mushkin Enhanced Mulholland 16GB USB flash drives, AKG K240 Studio headphones. |
03-23-2011
|
#6 | | Windows 7 Ultimate x64 Service Pack 1 |

Quote: Originally Posted by gogreen OK, OS. Great idea. I'll try that. Thanks.
And thanks oreo27. That might also work. No problem mate!  Cheers! | My System Specs | | System Manufacturer/Model Number Custom Built OS Windows 7 Ultimate x64 Service Pack 1 CPU AMD Athlon II x4 Propus 2.9 GHz Motherboard ASUS M2N68 AM-PLUS Memory Transcend 2 x 2 GB DDR2800 Graphics Card Sapphire Radeon HD 5670 1GB GDDR5 Sound Card On-board 6-Channel HD Audio, Split Audio via 3.5mm Splitter Monitor(s) Displays 22' Chimei 22QD Screen Resolution 1920 x 1080 Keyboard A4tech KL-126 Backlit Keyboard Mouse A4tech N400 Padless Mouse PSU Generic 600W Case Generic Transparent Side Cooling Generic 2 x 80mm Fans Hard Drives 1 x 80 GB SATA 7200 RPM
1 x 500 GB SATA 7200 RPM
1 x 1 TB Western Digital MyBook Essentials Internet Speed 1Mb/s DL, 0.9Mb/s UL Other Info Altec Lansing BXR 1221
Sennheiser HD201
ZTE Modem
Linksys WRT-54GH
Nokia C7-00 Hacked
Nokia E5-00 Hacked
Samsung ES65
1 X 4GB Bootable USB
1 X 2GB USB Flash Drive
1 X 2GB microSD Storage |
03-27-2011
|
#7 | | Windows 7 Home Premium x64 SP 1 |
I solved this problem by simply removing the "del c:\*.bak /s" line. That computer rarely has *.bak files, anyway. I'm just glad I discovered why I kept getting a message to install a feature when I tried to go into MS Office products! | My System Specs | | System Manufacturer/Model Number Dell Studio XPS 8100 OS Windows 7 Home Premium x64 SP 1 CPU Intel Core i7 860 @ 2.8 GHz Motherboard Dell 0T568R (CPU1) Memory 8.0 GB Dual Channel DDR3 @ 664 MHz (9-9-9-24) Graphics Card nVidia GeForce GTS 240 Sound Card M-Audio Delta Audiophile 2496 Monitor(s) Displays Dell 2407WFP Screen Resolution 1920x1200 Hard Drives 977 GB Western Digital WDC WD1001FAES-75W7A0 (SCSI) Other Info Microsoft Security Essentials, Mozilla Firefox, Mozilla Thunderbird. M-Audio Keystation 88es (keyboard controller), Western Digital Passport 250 GB external HD, Logitech Z2300 speaker system, two Mushkin Enhanced Mulholland 16GB USB flash drives, AKG K240 Studio headphones. |
03-27-2011
|
#8 | | Windows 7 Ultimate x64 Service Pack 1 |

Quote: Originally Posted by gogreen I solved this problem by simply removing the "del c:\*.bak /s" line. That computer rarely has *.bak files, anyway. I'm just glad I discovered why I kept getting a message to install a feature when I tried to go into MS Office products!  Well, at least you're satisfied now. Congratulations mate! | My System Specs | | System Manufacturer/Model Number Custom Built OS Windows 7 Ultimate x64 Service Pack 1 CPU AMD Athlon II x4 Propus 2.9 GHz Motherboard ASUS M2N68 AM-PLUS Memory Transcend 2 x 2 GB DDR2800 Graphics Card Sapphire Radeon HD 5670 1GB GDDR5 Sound Card On-board 6-Channel HD Audio, Split Audio via 3.5mm Splitter Monitor(s) Displays 22' Chimei 22QD Screen Resolution 1920 x 1080 Keyboard A4tech KL-126 Backlit Keyboard Mouse A4tech N400 Padless Mouse PSU Generic 600W Case Generic Transparent Side Cooling Generic 2 x 80mm Fans Hard Drives 1 x 80 GB SATA 7200 RPM
1 x 500 GB SATA 7200 RPM
1 x 1 TB Western Digital MyBook Essentials Internet Speed 1Mb/s DL, 0.9Mb/s UL Other Info Altec Lansing BXR 1221
Sennheiser HD201
ZTE Modem
Linksys WRT-54GH
Nokia C7-00 Hacked
Nokia E5-00 Hacked
Samsung ES65
1 X 4GB Bootable USB
1 X 2GB USB Flash Drive
1 X 2GB microSD Storage |
03-27-2011
|
#9 | | Windows 7 Home Premium x64 SP 1 |

Quote: Originally Posted by oreo27 
Quote: Originally Posted by gogreen I solved this problem by simply removing the "del c:\*.bak /s" line. That computer rarely has *.bak files, anyway. I'm just glad I discovered why I kept getting a message to install a feature when I tried to go into MS Office products!  Well, at least you're satisfied now. Congratulations mate!  Yeah, thanks. Sometimes it takes a little thinking to come up with the obvious solution! | My System Specs | | System Manufacturer/Model Number Dell Studio XPS 8100 OS Windows 7 Home Premium x64 SP 1 CPU Intel Core i7 860 @ 2.8 GHz Motherboard Dell 0T568R (CPU1) Memory 8.0 GB Dual Channel DDR3 @ 664 MHz (9-9-9-24) Graphics Card nVidia GeForce GTS 240 Sound Card M-Audio Delta Audiophile 2496 Monitor(s) Displays Dell 2407WFP Screen Resolution 1920x1200 Hard Drives 977 GB Western Digital WDC WD1001FAES-75W7A0 (SCSI) Other Info Microsoft Security Essentials, Mozilla Firefox, Mozilla Thunderbird. M-Audio Keystation 88es (keyboard controller), Western Digital Passport 250 GB external HD, Logitech Z2300 speaker system, two Mushkin Enhanced Mulholland 16GB USB flash drives, AKG K240 Studio headphones. All times are GMT -5. The time now is 01:07 AM. |  |