Batch programming help

Associate
Joined
22 Sep 2009
Posts
2,085
Location
Leicester
I'm using Windows and trying to recursively go through folders and delete all images and various other files in a directory (I.E. not leak up and remove all my photos :D)

Not done much batch on Windows so I'm having issues (took me a few minutes to figure out /?)

Code:
DEL /S /ARH *.jpg
I would expect this to delete all jpg images in all subdirectories, whether hidden or not, however it just gives me
Could Not Find [DIRECTORY]*.jpg
Is my wildcard wrong or something?
 
./*.jpg gives an error (invalid switch).

The rest of the stuff you posted confused me... off to read on batch coding to stop being such a noob, I find a lot of times batch would be easier and quicker than manual/compiled code. Hopefully I'll make sense of what you posted by the time I've finished :)
 
Thanks for the reply, I read through the documentation and figured out a few other things, however I'm having an issue getting the script working in folders where there is a space in the name, and CMD /X doesn't appear to work when calling a script, other than that I'm not sure what I can do.

Also, is the correct way to run this
delete_images *.jpg
Just want to make sure that I don't end up killing everything.

Cheers again.
 
CMD /X is extensions, I'm pretty sure it used to be used to stop CMD treating spaces as a delimiter, however doesn't seem the case on Vista...

How do I supply the address of each subfolder enclosed with ""'s? This is being the main issue, folders without spaces work nicely but as the majority have spaces in it doesn't work.

To be fair I think I know too little about CMD to make much sense of a lot of those sites and I don't really have the patients to learn it for this. If I'm just getting this all back to front let me know and I'll switch to C, might be extra work but saves wasting your time :)
 
Cheers, you must have got that other post in just before me :p

It worked, maybe VB scripting is the way forward, shame there's no Cscript :rolleyes:
 
That's what I was referring to, the script is collecting the subfolders but supplying them without ""'s so it's not working. I was just wondering how I could get around that.
 
Back
Top Bottom