![]() | |
|
Welcome to the ABXZone Computer Forums forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 |
| Registered User Join Date: Mar 2006
Posts: 4
| Hi I'm trying to create a batch file to automatically remove directories beginning with "$" in the C:\Windows directory as they're not needed and take up way too much space. I can't seem to get rmdir to do this with wildcards and deltree isn't on XP (my OS). Can someone write out a DOS command line for me which will do this? Thanks Dave |
| (Offline) | |
| | #2 |
| Registered User Join Date: May 2003 Location: NY
Posts: 244
| Re: Deleting directories via DOS using wildcards Assuming you have administrative rights, just open Windows Explorer, highlight all the folders beginning with "$" and hit delete. They will be deleted.
__________________ ASUS P5KC || Corsair PC3-10664 2GB (2x1024) @ 1333MHz FSB || Intel C2D E6850 || 2X WD 150 GB Raptor || Enermax Infiniti 720W PSU || eVGA GeForce 8800 Ultra KO, 768 MB, 175.16 Driver || Lite-On LH-20A1S CD/DVD-RW Drive || Sony DDU1615, 16/48 DVD-ROM Drive || ProCase Full Tower || Dell 2707WFP 27" Monitor @ 1920x1200 || Cambridge SoundWorks 'MicroWorks' Speakers || Windows XP Pro/32 bit/SP3 |
| (Offline) | |
| | #3 |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 383
| Re: Deleting directories via DOS using wildcards Try the following command: for /d %a in ($*) do rmdir /s /q %a This will remove any folders (and subfolders) in the current directory that start with a $. The for command is useful for things like this. Oh yes -- and you can change this to point to the appropriate path, or do a cd at the beginning of the batch file. Either will work. Logan |
| (Offline) | |
| | #4 |
| Registered User Join Date: Mar 2006
Posts: 4
| Re: Deleting directories via DOS using wildcards Thanks Logan, that works if I type it in to the command prompt but doesn't from a batch file! It keeps saying "a was unexpected at this time", any ideas??? This is the batch file code I'm using: c: cd\windows for /d %a in ($*) do rmdir /s /q %a |
| (Offline) | |
| | #5 |
| Registered User Join Date: Jan 2003 Location: Blue Ridge Mountains, VA
Posts: 383
| Re: Deleting directories via DOS using wildcards Yeah, sorry about that. From a batch file, you have to double up the percent signs. So, in a batch file, the line would be: for /d %%a in ($*) do rmdir /s /q %%a Two % signs in front of each a. That's just one of those flaky things about the command prompt versus batch engine in Windows. Logan |
| (Offline) | |
| | #6 |
| Registered User Join Date: Mar 2006
Posts: 4
| Re: Deleting directories via DOS using wildcards Weird, but it works now! Thank you so much, I was tearing my hair out trying to figure this out, you're a genius! |
| (Offline) | |
| | #7 | |
| Registered User Join Date: Jun 2008
Posts: 65
| You can modify something like this to fit your own needs... Quote:
I'd be carefull though | |
| (Offline) | |
| | #8 |
| Registered User Join Date: Mar 2006
Posts: 4
| Re: Deleting directories via DOS using wildcards Ha ha, yeah I will be careful, I did get one of the lines wrong in my batch file and it started deleting all files in the Windows directory! Managed to stop it in time tho, just had to rebuild the fonts folder. Deltree isn't available in XP, but will have a look at this and modify, definitely of interest |
| (Offline) | |
| | #9 | |
| Registered User Join Date: Jun 2008
Posts: 65
| Re: Deleting directories via DOS using wildcards This one is for XP/2000... Quote:
| |
| (Offline) | |
![]() |
| Thread Tools | |
| Display Modes | |
| |