Small Batch File - HELP


I tried to make a little batch file that deletes all jpg's taken with my camera. And it does not work. I don't know how to change the code in order to iterate all my partitions of my harddisk and if it founds something, the it deletes it.

Here is the code, please help:

@echo off
echo Loading...
for %%d in (c,d,e,f,g) do (
if exist %%d: for /R %%d: %%G in (*IMG_00*.jpg *IMG_10*.jpg) do del /p /s "%%G"
echo Deleted


  • :::To be on the safe side this will move the files into a folder on the c: drive! You can then delete them from there.

    @echo off

    SetLocal EnableDelayedExpansion

    for /f "tokens=2* delims=: " %%i in ('fsutil fsinfo drives') do (
    set drive=%%i

    for /f %%m in ('dir /b /s !drive!:*IMG_*.jpg') do (
    ECHO %%m >>c:files_to_be_deleted.txt


    md c:files_for_Deletion

    for /f %%i in (c:files_to_be_deleted.txt) do (
    MOVE %%i c:files_for_Deletion

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


In this Discussion