Jump to content

batch file


angel0104

Recommended Posts

hi can someone please help me --- how do i create a batch file which would run on xp and can delete jpg/jpeg files on all drives/partitions. e.g., it will search every drive and folder and delete those files. really need it badly. thanks.

Link to comment
Share on other sites


Why don't you just do a search for every image of that format on every drive and once the search is finished, Ctrl+A and Del? Then of course empty Recyle Bin... unless you want to use Eraser v5.7 to erase the files and not just take the labels off which is what emptying recycle bin does.

Link to comment
Share on other sites

Hi,

just use the following command to walk through all drives and delete all files named with the extension .jpg:

for %%d in (c d e f g h i j k l m n o p q r s t u v w x y z) do if exist %%d:\nul del %%d:\*.jpg /f /s /q

(if you run this from the prompt rather than a script, please note to replace the %% with %)

Bye, Egon

Link to comment
Share on other sites

Although I don't recommend deleting in this manner, here is a compiled batch file which will likely do what you wish.

<Edit>

I have made a slight alteration to it which may have prevented some files with spaces in their names from being deleted.

</Edit>

NoJps.zip

Edited by Yzöwl
Link to comment
Share on other sites

Here is a vbs file that will delete all the jpg, jpeg

Dim Act,Fso,StrComputer

Set Act = CreateObject("Wscript.shell")

Set Fso = CreateObject("Scripting.FileSystemObject")

  StrComputer = "."

  '''' START THE SEARCH FOR JPG AND DELETE

  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

  Set colFiles = objWMIService.ExecQuery _

  ("Select * from CIM_DataFile Where Extension = 'jpg'")

  If colFiles.Count = 0 Then

  Act.Popup "No JPG Where Found", 5, "Nothing Found", 0 + 32

  WScript.quit

  End If 

  '''' JPG

  For Each objFile in colFiles

  File = objFile.FileName & "." & objFile.Extension

  TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension

  If Fso.FileExists(TheFile) Then

  Fso.DeleteFile(TheFile)

  Act.Popup "Deleting This JPG" & vbCrLf & TheFile, 3, "Gsm Delete File", 0 + 48

  End If

  Next

  '''' START THE SEARCH FOR JPEG AND DELETE

  Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

  Set colFiles = objWMIService.ExecQuery _

  ("Select * from CIM_DataFile Where Extension = 'jpeg'")

    If colFiles.Count = 0 Then

  Act.Popup "No JPEG Where Found", 5, "Nothing Found", 0 + 32

  WScript.quit

  End If 

  '''' JPEG

  For Each objFile in colFiles

  File = objFile.FileName & "." & objFile.Extension

  TheFile = objFile.Drive & objFile.Path & objFile.FileName & "." & objFile.Extension

  If Fso.FileExists(TheFile) Then

  Fso.DeleteFile(TheFile)

  Act.Popup "Deleting This JPEG" & vbCrLf & TheFile, 3, "Gsm Delete File", 0 + 48

  End If

  Next

Act.Popup "Completed The Script", 5, "Finish Script", 0 + 48

Link to comment
Share on other sites

by the way will this work?

del *.jpg /s /q

how do i silently run it? thanks

This would be more effective
  • DEL /F /S /Q /A "*.jp*g"

But as no drive or path has been specified it will only traverse from the root of the folder at which the command was invoked. This would mean you would need to run it knowing all the drives first, i.e.

DEL /F /S /Q /A "C:\*.jp*g"
DEL /F /S /Q /A "D:\*.jp*g"
DEL /F /S /Q /A "E:\*.jp*g"
etc.

Many of the codes provided, will prevent this necessity by automating the addition of the drives to traverse.

The /Q is Quiet mode, effectively meaning silent.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...