I have a folder with .dng files and .jpg files.
They are the same files but with different file formats.
After I've deleted some of the jpg-files - I'd also like to remove the dng files.
I end up having a folder like this:
File1.dng
File1.jpg
File2.dng
File2.jpg (deleted)
File3.dng
File3.jpg
File4.dng
File4.jpg (deleted)
I then like to remove the corresponding dng-files.
How do I get TC to remove the File4.dng and File2.dng in the example above?
Match file pairs with file extension
Moderators: white, Hacker, petermad, Stefan2
PowerShell: Match file pairs with file extension
maglet wrote: ↑2020-05-03, 15:29 UTC I have a folder with .dng files and .jpg files.
They are the same files but with different file formats.
After I've deleted some of the jpg-files - I'd also like to remove the dng files.
I end up having a folder like this:
File1.dng
File1.jpg
File2.dng
File2.jpg (deleted)
File3.dng
File3.jpg
File4.dng
File4.jpg (deleted)
I then like to remove the corresponding dng-files.
How do I get TC to remove the File4.dng and File2.dng in the example above?
PowerShell
dir *.dng|%{$B=$_.BaseName; IF(-Not(Test-Path "$B.jpg")){"$B.JPG not found, delete $($_.Name)"}}
File2.JPG not found, delete File2.dng
File4.JPG not found, delete File4.dng
Add a function to actual delete the files without an buddy instead of just put out the text string.
Or copy the wanted files names to clipboard, next use "Get Selection from Clipboard"
and you have the files selected to work on, for example use "Show only Selected Files".
To have all available internal commands in menu I can recommend
"Extended English Menus for Total Commander" (by petermad) >> http://www.totalcmd.net/authors/1223914.html
For to add to the clipboard, utilize DOS-Command CLIP (problem with umlauts):
$OUT='';dir *.dng|%{$B=$_.BaseName; IF(-Not(Test-Path "$B.jpg")){"$B.JPG not found, delete $($_.Name)";$OUT+=$($_.Name)+"`r`n"}}; $OUT|clip
Or utilize an commandlet if available (needs PoSh v4 or v5? or an own created commandlet):
$OUT='';dir *.dng|%{$B=$_.BaseName; IF(-Not(Test-Path "$B.jpg")){"$B.JPG not found, delete $($_.Name)";$OUT+=$($_.Name)+"`r`n"}}; $OUT|Set-Clipboard
Re: Match file pairs with file extension
2maglet
1. Press Num+ (or Mark -> Select Group)
2. Enter: *.jpg > *.dng
3. Press OK
Now all matching jpg/dng pairs (File1.* and File3.*) are marked
4. Press Num * (or Mark -> Invert Selection)
Now File4.dng and File2.dng should be marked.
1. Press Num+ (or Mark -> Select Group)
2. Enter: *.jpg > *.dng
3. Press OK
Now all matching jpg/dng pairs (File1.* and File3.*) are marked
4. Press Num * (or Mark -> Invert Selection)
Now File4.dng and File2.dng should be marked.
Help wrote:Selecting files
.
.
.You can also select related files. For example, you would want to select all RAW image files (.cr2), but only if there is a jpg file in the same directory. This can be done with the following selection string:
*.jpg>*.cr2
This also supports more complex naming schemes. For example, if the jpg file is named IMG_1057.JPG and the raw file CRW_1057.CR2, the selection string would have to be:
*.jpg>crw*.cr2
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Re: Match file pairs with file extension
...and so are any other unrelated files too.
You just have to know and to take care.
Re: Match file pairs with file extension
Thanks for all replies! All methods worked out fine.
I've been using TC as a registered user for many years - and still missing the help section pointing out exactly what I want do do
TC is amazing!
I've been using TC as a registered user for many years - and still missing the help section pointing out exactly what I want do do
TC is amazing!
Re: Match file pairs with file extension
2maglet
Maybe this is what you want:and still missing the help section pointing out exactly what I want do do
- Open Help
- Click on the Index tab
- Type: Selecting files
- Double click on "Selecting files" in the list
- Click on "Selecting files" in the bottom of the main window.
License #524 (1994)
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar
Danish Total Commander Translator
TC 11.03 32+64bit on Win XP 32bit & Win 7, 8.1 & 10 (22H2) 64bit, 'Everything' 1.5.0.1371a
TC 3.50 on Android 6 & 13
Try: TC Extended Menus | TC Languagebar | TC Dark Help | PHSM-Calendar