delete specific jpg files from folders and subfolders using Excel VBA
Dear Experts:
I understand that it is possible to delete files from a folder using Excel VBA
I am running Excel 2010 on Windows 7
I would like to delete specific jpg files from a directory with many folders and subfolders. The directory's name is ...
... C\Graphics\...
The jpg files that are to be deleted are only those that have the following characters at the end:
_h.jpg or _n.jpg, i.e. for example 90-147-58-30_h.jpg or 94-111-24-39_n.jpg. All other jpg files that do not match these criteria are not to be touched.
Help is very much appreciated. Thank you very much in advance.
Kind regards, Andreas
Microsoft ExcelVBA
Last Comment
Professor J
8/22/2022 - Mon
Saurabh Singh Teotia
So just to make sure if i understand this correctly you want to delete all the jpg files from folder and sub-folder which ends with h or n?
thank you very much for your professional help. I am sure that your DOS-command works just fine, but I am afraid to tell you that I use Windows 7 64 bit and I understand that DOS-command won't run on a Windows 7 64 bit system.
You were mislead by my usage of "DOS" - it's used sometimes for the good old-fashioned batch file stuff, as I used it here. I meant "cmd.exe batch". Start a command prompt, and try my code.
Doing that in VBA or VBS requires much more of code.
Am I right, I press the Windows Key + R to bring up the Run Window. And then I enter cmd.exe to launch the command prompt. The window in the command prompt says: C:\Users\Andreas>
I then enter your command prompt right after the 'greater than' sign, am I right?
Regards, andreas and thank you very much for your help.
works really great, thank you very much for your professional support. I really appreciate it.
Dear Qlemo and ProfJimJam,
Since I was initially asking for a VBA solution, I will award more points to ProfJimJam.
You both deserve 500 points, but regrettably this is not possible. Again, thank you very much for your superb, swift and professional help. This forum has saved me days and months of tedious and exhausting work.
Have a nice day, regards, Andreas
Professor J
Thank you Andreas for your nice feedback
Wish you a nice day too
Regards
Is my understanding correct?
Saurabh..