Utility to conditionally delete files with same name

Discussion in 'Windows 7 Help and Support' started by dilipb, Nov 11, 2013.

  1. dilipb

    dilipb Well-Known Member

    Joined:
    Sep 12, 2011
    Messages:
    32
    Likes Received:
    0
    I am a photographer and generate "raw" and JPG images. At a certain point in my workflow, I need to delete all the JPG images before proceeding. That's easy enough; in Windows Explorer, one can sort by type, then delete all the JPGs, or one could open up a command prompt in the directory and "erase *.jpg". But there's a complication; in some modes of the camera, no raw file is generated. In those cases, I just have one .jpg that I want to keep. Here is an example:

    img1.cr2
    img1.jpg
    img2.cr2
    img2.jpg
    img3.jpg
    img4.cr2
    img4.jpg

    I want to process this directory and end up with one file of each filename, as follows:

    img1.cr2
    img2.cr2
    img3.jpg
    img4.cr2

    The pseudocode would go something like this:

    Sort files by filename fname

    IF fname.jpg and fname.cr2 both exist THEN delete fname.jpg

    How can I easily do this? Thanks!

    Dilip
     
  2. Pauli

    Pauli Extraordinary Member
    Premium Supporter

    Joined:
    Mar 1, 2012
    Messages:
    2,499
    Likes Received:
    211
    I'm a photographer too, howdy partner!

    Primarily, I would recommend to do it the hard way = manually. That way you know what has been done. Period. Takes a lot of mule work, but it's kind of safe. Considering the years I have spent in the darkroom... it doesn't sound that laborious.

    Are you really and truly sure you want to automatically delete stuff? The automate has its dark side. Just an opinion. :scratch:
     
  3. dilipb

    dilipb Well-Known Member

    Joined:
    Sep 12, 2011
    Messages:
    32
    Likes Received:
    0
    Thanks! No, I would want a confirmation dialog. But doing it manually, as I currently do, can be time consuming! Thanks.
     
  4. whs

    whs Extraordinary Member

    Joined:
    Sep 17, 2009
    Messages:
    1,541
    Likes Received:
    106

Share This Page

Loading...