Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

Batch Program Help


  • Please log in to reply
4 replies to this topic

#1 pntblltrc4

pntblltrc4

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:17 PM

Posted 30 November 2010 - 10:12 PM

Ok here is the question. I need to build a batch file that will search the c: drive for a given file, if that file exists I need it to delete it. Is it possible to do this with batch, or am I hitting its limitation? If its possible could someone please give me and example how the string should look.

Thank You For Your Help Everyone

Aaron
Isaiah 54:17
No weapon that is formed against thee shall prosper; and every tongue [that] shall rise against thee in judgment thou shalt condemn. This [is] the heritage of the servants of the LORD, and their righteousness [is] of me, saith the LORD.

BC AdBot (Login to Remove)

 


#2 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:12:17 PM

Posted 30 November 2010 - 11:11 PM

You want to make a batch file but did you try the DEL command ?

DEL /S can delete matching files from all sub-folders. Use very carefully. Type DEL /? to see all options.

#3 pntblltrc4

pntblltrc4
  • Topic Starter

  • Members
  • 13 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:01:17 PM

Posted 30 November 2010 - 11:27 PM

YOU ARE MY HERO!!!!!!!!!!!! By chance you would know how to take all the results of my .bat file and export them into a single log.txt?
Isaiah 54:17
No weapon that is formed against thee shall prosper; and every tongue [that] shall rise against thee in judgment thou shalt condemn. This [is] the heritage of the servants of the LORD, and their righteousness [is] of me, saith the LORD.

#4 Romeo29

Romeo29

    Learning To Bleep


  • Members
  • 3,194 posts
  • OFFLINE
  •  
  • Gender:Not Telling
  • Location:127.0.0.1
  • Local time:12:17 PM

Posted 01 December 2010 - 12:49 AM

In your batch file
Put > followed by logfile pathname to write output of command to new log file.
Put >> in the same way to append to an already existing log file.

For example,

DIR C: > c:\mylogfile.txt
DIR C:\Windows >> c:\mylogfile.txt

Do this wherever needed. You can do fancy stuff too, like putting in date and time at the beginning of log :

SET LogFile=C:\mylogfile.txt
ECHO. >> %LogFile%
ECHO %Date% >> %LogFile%
ECHO %Time% >> %LogFile%
ECHO. >> %LogFile%


#5 JosiahK

JosiahK

  • Members
  • 269 posts
  • OFFLINE
  •  
  • Gender:Male
  • Local time:06:17 PM

Posted 03 December 2010 - 09:10 AM

Be aware that the del command will remove all files by that name, and only works against that name. If there are other files with the same name they'll be deleted as well. If you want to delete every case of a specific file (name and contents are both the same) you could get a bit of a safeguard by checking that the file size or date are the same.
Quod non mortiferum, fortiorem me facit.
I don't read minds. Please help everyone by answering any questions and reporting on the results of any instructions. Query any concerns and explain problems or complications.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users