jnelsoninjax Posted September 19, 2022 Share Posted September 19, 2022 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 More sharing options...
Joe User Posted September 19, 2022 Share Posted September 19, 2022 What do you mean by "path" *.jpg? Something like c:\temp\*.jpg or did you want a variable for path? Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762574 Share on other sites More sharing options...
Jim K Global Moderator Posted September 19, 2022 Global Moderator Share Posted September 19, 2022 del /s "c:\path of images\*.jpg" that should delete jpg's from "path of images" and all its subdirectories. ....you can't retrieve files after using DEL Joe User 1 Share Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762575 Share on other sites More sharing options...
jnelsoninjax Posted September 19, 2022 Author Share Posted September 19, 2022 The exact command I used was: del "C:\Program Files\Agent\Media\WebServerRoot\Media\video" *.jpg /s Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762576 Share on other sites More sharing options...
theefool Posted September 19, 2022 Share Posted September 19, 2022 (edited) 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" jnelsoninjax 1 Share Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762577 Share on other sites More sharing options...
Jim K Global Moderator Posted September 19, 2022 Global Moderator Share Posted September 19, 2022 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. Joe User and jnelsoninjax 1 1 Share Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762578 Share on other sites More sharing options...
jnelsoninjax Posted September 19, 2022 Author Share Posted September 19, 2022 (edited) 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) Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762579 Share on other sites More sharing options...
binaryzero Posted September 19, 2022 Share Posted September 19, 2022 The syntax has been the same forever. I suggest learning PowerShell, far superior to cmd\batch files. Matthew S. and sini 2 Share Link to comment https://www.neowin.net/forum/topic/1421588-help-with-creating-a-batch-file/#findComment-598762596 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now