The folder may contain the following types of file names:
filename.imageExtension
filename.imageExtension.sidecarExtension
filename.sidecarExtension
The extensions are as follows:
imageExtension can be a number type extensions .nef, .raf, .orfetc.
sidecarExtension may be multiple extensions, such as: .xmp, .pts, .pp3etc.
So, in a folder, I could, for example, have files such as:
tree.nef
tree.nef.pp3
car.raf
car.xmp
car.raf.pp3
house.xmp
something.nef.pp3
In this case, house.xmpand something.nef.pp3are orphans who should be removed . What determines that these files are lost is that there is no corresponding image file (a file with the same name but with imageExtension and without sidecarExtension).
Is there a way to delete all orphaned files and only orphaned files with a bash script?
, :
if [[ -e $(echo "$filename" | sed "s/"$imageExtension"/"$sidecarExtension"/g" ) ]]
if [[ -e $(echo "$filename" | sed "s/"$imageExtension""$sidecarExtension"/"$sidecarExtension"/g" ) ]]
, .