Scripts Thread, Script to delete specific folders in Coding and Web Development; Hi,
I am new to scripting! Please excuse me if I display any dumbness over the post!
I am interning ...
5th June 2008, 02:56 AM #1
5th June 2008, 01:13 PM #2
Remove directorie with batch file:
The command for this should be something like this (as long as you are working from the machine your directories reside on) if Iím not mistaken:
RMDIR X:\YOURPATHNAME\HOMEFOLDER$ /s /q
/s being to remove all subdirectories
/q being to do it without confirmation
Note that you cannot be inside the directory that you are deleting; else you will be prompted with the message "The process cant access the folder because it is being used by another process".
If your text file is prepared as follows (and the majority of your home folders reside in one or two locations then you could do the following:
Imagine this is a few lines of your text file:
Use the edit menu and choose to replace:
In the find box enter:
In the replace box enter:
RMDIR X:\Users\Home Folders\
Then choose replace all:
Repeat this for any other locations you might have then concentrate on adding the switches Ė again by using find and replace.
In the find box choose to find a $ sign and choose to replace it with $ /s /q
(Obviously your directories need to end in $ signs)Ö
Now save the text file as a .bat file.
The script should then do the rest when you run it. Needless to say be sure you are targeting the right folders, Iím sure someone here will point out if Iíve made any mistakes with this..
Thanks to superfletch from:
Baasha_Bhai (5th June 2008)
5th June 2008, 08:22 PM #3
- Rep Power
Thank You for your timely suggestions guys. Let me work on it and get back to you!
5th June 2008, 08:32 PM #4
- Rep Power
Don't forget the quotes
The suggestions look good to me, but I always
forget to put quotes around the directory names
and some of the names have spaces in them.
rd "Folder To Remove"
rd Folder To Remove
6th June 2008, 06:34 PM #5
- Rep Power
Thanks for teaching an old dog a new trick - I've never heard of this feature.
Now that I'm an "expert", I might suggest:
1. CMD prompt
2. EDIT killfile.txt in case mistakes occur that need to be fixed.
Thanks again for the tip
6th June 2008, 06:45 PM #6
9th June 2008, 02:19 PM #7
thanks for that, I'm sure I'll need it one day!
1st July 2008, 10:00 PM #8
You could just start writing the folder name and use tab!!
Originally Posted by jinnantonnix
Sorry couldn't help it.
2nd July 2008, 10:41 AM #9
Some may find this handy....
You will need to compile it first - [ I did it in AutoIT ]
When run it will delete all the files & folders in the directory apart from the folder 'keep me'
I run this every year on our students home directories.
If you want a compiled version - just ask and I'll copy it up...
$search = FileFindFirstFile("*.*")
; Check if the search was successful
If $search = -1 Then
MsgBox(0, "Error", "No files/directories matched the search pattern")
$file = FileFindNextFile($search)
If @error <> 0 Then ExitLoop
If $file = "keep me" Then ContinueLoop
If $file = "." Or $file = ".." Then ContinueLoop
If StringInStr(FileGetAttrib(@SCRIPTDIR & "\" & $file) , "D") Then
FileDelete(@SCRIPTDIR & "\" & $file)
Last Post: 4th June 2008, 12:30 PM
By Pumaedition in forum Scripts
Last Post: 22nd April 2008, 10:08 PM
By JPhillips173 in forum Scripts
Last Post: 17th April 2008, 11:25 AM
By projector1 in forum Scripts
Last Post: 9th March 2008, 12:15 AM
By timbo343 in forum Scripts
Last Post: 19th September 2007, 10:46 PM
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)