--[[ Loops through selected raw files and deletes any matching sidecar JPEGs SETUP INSTRUCTIONS Temporarily save this file onto your desktop and call it "YOURFILENAME.lua". Now you need to create a scripts folder: In Lightroom, choose Lightroom > Preferences (Mac OS) or Edit > Preferences (Windows). Choose the Preset tab and select Show Lightroom Presets folder. Create a folder in the Lightroom folder called Scripts. Copy the "YOURFILENAME.lua" script into the Scripts folder. Quit and reopen Lightroom. You should now see a little scripts menu to the right of the Help menu. It has a single item Title case keywords. --]] local LrPathUtils = import 'LrPathUtils' local LrFileUtils = import 'LrFileUtils' local LrTasks = import 'LrTasks' local LrDialogs = import 'LrDialogs' local ProgressScope = import 'LrProgressScope' local SEP if MAC_ENV then SEP = '/' else SEP = '\\' end myCommand = {} myCommand.progressTitle = 'Purge matching JPEGs' function myCommand.myRoutine() LrTasks.startAsyncTask( function() local JPEGsWhacked = 0 local RawFiles = 0 local catalog = import "LrApplication".activeCatalog() photos = catalog:getTargetPhotos() local ProgressScope = ProgressScope({ title = myCommand.progressTitle, caption = '', }) for i, photo in ipairs(photos ) do if photo:getFormattedMetadata( "fileType" ) == 'Raw' then path = photo:getRawMetadata("path") fileName = photo:getFormattedMetadata("fileName") jpegPath = LrPathUtils.replaceExtension( path, 'jpg' ) if LrFileUtils.exists( jpegPath ) == 'file' then LrFileUtils.moveToTrash(jpegPath) JPEGsWhacked = JPEGsWhacked + 1 end RawFiles = RawFiles + 1 ProgressScope:setCaption("Item : " .. i .. ' File name: ' .. fileName) ProgressScope:setPortionComplete( i, #photos ) end end ProgressScope:done() LrDialogs.showBezel("Finished - deleted " .. JPEGsWhacked .. " JPEGs for " .. RawFiles ..' raw files from '.. #photos .. " files" , 5) end) end myCommand.myRoutine()