Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Batch file to remove files & folders?

- - - - -

  • Please log in to reply
19 replies to this topic

#1
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Hi, I have tried to get batch working for months, but nothing was not able to tell, what to do, even Google failed. Then I have found The Avenger and I used that one on XP to remove files, but since I have moved to Vista and that software does not work there, I have the same problem as I had before. I just need to know, how does it work, so I would be able to edit it. If you have any idea, please write it down.


How to remove advertisement from MSFN

#2
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,077 posts
  • OS:none specified
  • Country: Country Flag

I have tried to get batch working for months


WHICH batch file? :blink:

jaclaz

#3
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Any batch files I have found around, even that one created by the avenger.
But it looks, like it just does not like me and it never works, no matter what.

#4
jondercik

jondercik

    Advanced Member

  • Member
  • PipPipPip
  • 445 posts
Post the code you use
Jim
R.I.P. Alienware
1996-2006

#5
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,077 posts
  • OS:none specified
  • Country: Country Flag
Yep, and possbly under which operating system you are trying to run them....

jaclaz

#6
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
what are you trying to remove?

#7
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts

what are you trying to remove?

I did a clean instal of WinXP about once per week and The Avenger helped me to get rid of files like WMP's network sharing and other junk. An examle from Vista:
C:\Users\...\Favorites\Links
C:\Users\...\Favorites\Microsoft Websites
C:\Windows\Prefetch
C:\Windows\SoftwareDistribution

Edited by TheTOM_SK, 12 December 2006 - 08:28 AM.


#8
jondercik

jondercik

    Advanced Member

  • Member
  • PipPipPip
  • 445 posts
You still havent posted the code you are using, cant help you until you do that.

Jim
Jim
R.I.P. Alienware
1996-2006

#9
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
I folowed tutorial like this one and even simple bat did not work:
DELTREE C:\NewFolder
DR
I would never try to use bat, but removing files one by one take houres. Posted Image

Edited by TheTOM_SK, 15 December 2006 - 02:36 AM.


#10
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
Well for starters deltree does not exist in windows xp or vista.

To delete files from subdirectory trees use del /s names

Deletes one or more files.

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.


to delete the directory tree and its contents use RD /s path

Removes (deletes) a directory.

RMDIR [/S][/Q] [drive:]path
RD [/S] [/Q] [drive:]path

/S Removes all directories and files in the specified directory
in addition to the directory itself. Used to remove a directory
tree.

/Q Quiet mode, do not ask if ok to remove a directory tree with /S



#11
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Thanks for the detail description IcemanND.
I tried various command, but it did not work:
RD [/S] [/Q] C:\New Folder
RD [/S] [/Q] [C:]New Folder
RD [/S] [/Q] [C:\New Folder]
RD [/S] [/Q] [drive:] C:\New Folder


#12
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
the brackets denote optional parameters.

RD /S /Q C:\New Folder


#13
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Thanks, but it does not work. Hmm, I have just read, that bat only marks it as removed, so new files can rewrite it, but it is not actually removed. Or maybe Vista just does not handle bat properly. Posted Image

#14
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
change the extension from BAT to CMD

#15
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
I changed bat to cmd and it does not work (screen). :(

I wonder, if there is any freeware software, which can remove folders and files like The Avenger does? I do not care, if it is bat or a software as long as it will do its job.

Edited by TheTOM_SK, 15 December 2006 - 12:51 PM.


#16
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
add a pause to the CMD script, and enclose the folder in quotes, also remove the /q so you can see any possible errors:

RD /S "C:\New Folder"
pause


#17
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Awesome, it works now. Thank you for your great help. Posted Image
ECHO Y | RD /s "C:\New Folder"
ECHO Y | RD /s "C:\New Folder (2)"
ECHO Y | erase C:\File.txt


#18
IcemanND

IcemanND

    MSFN Junkie

  • Super Moderator
  • 3,266 posts
  • OS:Windows 7 x64
  • Country: Country Flag
if you put the /q back in then you can eliminate the "echo y |" most likely problem was because of the space in the path. the /q will bypass the confirmation.

#19
TheTOM_SK

TheTOM_SK

    Member

  • Member
  • PipPip
  • 138 posts
Yeah, you are right, thanks. Finally I can do as many clean instalations as I want. :D
rd /s/q "C:\New Folder"
rd /s/q "C:\New Folder (2)"
erase "C:\New Text Document.txt"


#20
MgmTest

MgmTest

    Junior

  • Member
  • Pip
  • 61 posts
  • OS:Windows 7 x86
  • Country: Country Flag
Hi.
Me Need Code For Found (Search) And Delete Drive And Folder.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN