Jump to content
LaunchBox Community Forums

BAT Files to Erase Duplicate Media (Same Name, Different Extension)


Recommended Posts

Geared mostly for older, bigger builds that have been around since before Launchbox had its media cleaning tools. After years of "updating" media on the same build I realized I had a lot of duplicates that had the same name but different extensions, .jpg or .png. Please note that when I say the word "duplicate" I'm not necessarily talking about identical images, just identically named images where one is being displayed in Launchbox and the other being ignored and taking up space.

Example of duplicate Box Art:

  Air Cars-01.jpg

  Air Cars-01.png

My build is huge and I wanted something to quickly "prefer" one file type and delete the other, so I cobbled together two bat files.

Running either bat will cause it to search through the folder for files with duplicated names with one version being a jpg and the other a png, and it will delete one of them. The bats will target the folder they are placed in and any subfolders in that directory. So you can use it just for Box Art, for example, by placing one directly in your boxart folder (this will also run in the regional folders within the boxart directory). Or you can use it for an entire system by placing it in your "images/system" folder. Or, for all systems at once by placing it directly in your /images folder.

Choose the ~PrefPNG~ version if you want to KEEP the png version of the duplicates

Choose the ~PrefJPG~ version if you want to KEEP the jpg versions of the duplicates. 

The bat does not do anything to any media that doesn't have identically named files, one with each of these extensions, in the same folder.*

WARNINGS:

These bats do not search for duplicates on ANY critera except for directory and NAME. They aren't looking for identical files, identical file sizes, time stamps or anything like that. If you have two completely different images, one jpg and one png, but they are named the same, it will delete one of them, and its up to you to look at your media and decide which "version" of the dupes you want to keep and pick the bat accordingly.

Not all media is created equal, so I would encourage you to use these in one system / art category at a time. It could be that for the box fronts, jpgs look better and for the box backs the pngs look better. 

Lastly, I know JUST enough about bat files to have pieced these together using other people's codes I found intended to do similar things, but beyond that, its all a mystery to me so here's the code in both the bats (just the extensions are switched in each version) if anyone wants to see it without downloading:

@ECHO OFF

FOR /F "usebackq delims=" %%i in ( `dir /b /s *.jpg` ) do (
    IF EXIST "%%~dpni.png" (
        DEL "%%i"
    )
)

Lagniappe: If you want to clean out the duplicates that launchbox may have downloaded and appended with a different number, e.g -02,-03 etc. you can do a search in the folder using this (type identically as seen below in the search):

"*-02*"

and that will search for all of the files with -02 in the title where you can delete them en masse if you wish. These are just tools I made and/or learned trying to clean up my oldest biggest launchbox build. 

Hope it helps!

Walter

 

 

~PrefPNG~ Delete Duplicates.bat ~PrefJPG~ Delete Duplicates.bat

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...