Hola,
Tengo un script Powershell para Windows que hice con esa misma idea, eliminar archivos .RAW sin un jpg asociado. Los jpg se buscan en la misma carpeta y descendientes y busco también formas "nombreraw_01.jpg" o "nombreraw 2.jpg" porque a veces revelo con más de una versión que he renombrado así y no he mantenido la original.
# del-no-jpg.ps1 Get all RAW files in directory
$Path = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
$arwFiles = Get-ChildItem -Path $Path -Include *.NEF, *.RAF, *.ORF, *.ARW -File -Recurse
# Iterate through each RAW file
foreach ($arwFile in $arwFiles) {
$arwFilePath = $arwFile.FullName
$arwFileName = $arwFile.Name
$arwBaseName = $arwFile.BaseName
$jpgFileName = $arwBaseName + "*.JPG"
# Check if a corresponding .JPG file exists in the same or child subdirectories
$jpgFiles = Get-ChildItem -Path $Path -Filter $jpgFileName -File -Recurse
if ($jpgFiles.Count -eq 0) {
# No corresponding .JPG file found, delete the RAW file
#Remove-Item -Path $arwFilePath -Force
$shell = New-Object -ComObject 'Shell.Application'
$shell.NameSpace(0).ParseName($arwFilePath).InvokeVerb('Delete')
Write-Output "Eliminado RAW $arwFileName sin JPG relacionado"
} else {
Write-Output "Se mantiene $arwFileName porque existe el JPG relacionado $jpgFileName"
}
}
Read-Host -Prompt "Press Enter to exit"
En esta versión los RAW se envían a la papelera por si quiero darles un último vistazo. Si se quieren eliminar directamente, hay que descomentar la línea #Remove-Item... y comentar las dos siguientes que empiezan por $shell...
Uso CaptureOne en la modalidad de sesiones. El script, un archivo al que le doy el nombre "del-no-jpg.ps1" lo copio en la carpeta de la sesión que quiero limpiar y lo ejecuto desde el explorador de Windows, botón derecho sobre el archivo, Ejecutar con PowerShell.
Saludos !
.