Help with creating a batch file


Recommended Posts

I tried to create a simple one line batch file that does del "path" *.jpg /s, but when I run it, it wants to del *.*, not *.jpg. The only way I have currently bypass this is is to use find in explorer. But that involves a few more steps. Is there any reason that that simple command structure is not working right? It's Windows 10.

Link to comment
https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/
Share on other sites

If you do it manually does it work?  as in:

 

dir /s "c:\path\to\directory\*.jpg" (to list)

del /s "c:\path\to\directory\*.jpg"

 

Powershell (Yes, not a .bat file, but .ps1)

 

Remove-Item 'c:\path\to\directory\*' -recurse -include *.jpg -whatif  (note: the -whatif lists the files it would delete).

 

  On 19/09/2022 at 01:10, jnelsoninjax said:

The exact command I used was: del "C:\Program Files\Agent\Media\WebServerRoot\Media\video" *.jpg /s

Expand  

Use:

del /s "C:\Program Files\Agent\Media\WebServerRoot\Media\video\*.jpg"

  • Thanks 1
  On 19/09/2022 at 01:10, jnelsoninjax said:

The exact command I used was: del "C:\Program Files\Agent\Media\WebServerRoot\Media\video" *.jpg /s

Expand  

 

del /s "C:\Program Files\Agent\Media\WebServerRoot\Media\video\*.jpg"

 

That will delete all .jpg under video and any subdirectory.

  • Like 1
  • Thanks 1
  On 19/09/2022 at 01:13, Jim K said:

 

del /s "C:\Program Files\Agent\Media\WebServerRoot\Media\video\*.jpg"

 

That will delete all .jpg under video and any subdirectory.

Expand  

OK, I'll try that, thanks. That worked! I guess I haven't done enough with the command line in the newer versions of Windows (I grew up using DOS and Win 3.1)

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.