MSFN Forum: Batch file to remove files & folders? - MSFN Forum

Jump to content


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Batch file to remove files & folders? If it only was as easy as reg files are. Rate Topic: -----

#1 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 12 December 2006 - 07:16 AM

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.


#2 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,456
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 12 December 2006 - 07:41 AM

TheTOM_SK said:

I have tried to get batch working for months


WHICH batch file? :blink:

jaclaz

#3 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 12 December 2006 - 07:49 AM

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 User is offline   jondercik 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 445
  • Joined: 15-January 04

Posted 12 December 2006 - 08:09 AM

Post the code you use

#5 User is offline   jaclaz 

  • The Finder
  • Group: Developers
  • Posts: 11,456
  • Joined: 23-July 04
  • OS:none specified
  • Country: Country Flag

Posted 12 December 2006 - 08:12 AM

Yep, and possbly under which operating system you are trying to run them....

jaclaz

#6 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 12 December 2006 - 08:13 AM

what are you trying to remove?

#7 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 12 December 2006 - 08:28 AM

View PostIcemanND, on Dec 12 2006, 04:13 PM, said:

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

This post has been edited by TheTOM_SK: 12 December 2006 - 08:28 AM


#8 User is offline   jondercik 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 445
  • Joined: 15-January 04

Posted 12 December 2006 - 09:58 AM

You still havent posted the code you are using, cant help you until you do that.

Jim

#9 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 02:36 AM

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

This post has been edited by TheTOM_SK: 15 December 2006 - 02:36 AM


#10 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 15 December 2006 - 07:20 AM

Well for starters deltree does not exist in windows xp or vista.

To delete files from subdirectory trees use del /s names

Quote

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

Quote

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 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 10:25 AM

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 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 15 December 2006 - 11:00 AM

the brackets denote optional parameters.

RD /S /Q C:\New Folder


#13 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 11:09 AM

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 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 15 December 2006 - 12:28 PM

change the extension from BAT to CMD

#15 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 12:51 PM

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.

This post has been edited by TheTOM_SK: 15 December 2006 - 12:51 PM


#16 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 15 December 2006 - 12:59 PM

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 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 01:12 PM

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 User is offline   IcemanND 

  • MSFN Junkie
  • Group: Super Moderator
  • Posts: 3,266
  • Joined: 24-September 03
  • OS:Windows 7 x64
  • Country: Country Flag

Posted 15 December 2006 - 01:47 PM

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 User is offline   TheTOM_SK 

  • Member
  • PipPip
  • Group: Members
  • Posts: 138
  • Joined: 13-June 06

Posted 15 December 2006 - 01:52 PM

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 User is offline   MgmTest 

  • Newbie
  • Group: Members
  • Posts: 32
  • Joined: 13-January 12
  • OS:Windows 7 x86
  • Country: Country Flag

Posted 17 January 2012 - 07:55 AM

Hi.
Me Need Code For Found (Search) And Delete Drive And Folder.

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

15 User(s) are reading this topic
0 members, 15 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2013 msfn.org
Privacy Policy