command to identify similar filenames [SOLVED]

Forum rules
Before you post please read how to get help
Post Reply
User avatar
52ROSt
Level 4
Level 4
Posts: 425
Joined: Mon Apr 14, 2014 10:01 am

command to identify similar filenames [SOLVED]

Post by 52ROSt »

LM 17.3 KDE 64

I have between 1000 - 2000 jpg-files in 2 folders. I can have files with the same name but a different files size and I want to keep both or keep the larger file.

Ist there a terminal command which either
keeps both files with and additional number at the end of the filename
or
keeps the larger files?

Thanks for your help!
Last edited by 52ROSt on Fri Jan 04, 2019 12:29 am, edited 1 time in total.

User avatar
xenopeek
Level 24
Level 24
Posts: 24276
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: command to identify similar filenames

Post by xenopeek »

Moved this to the scripting forum as I think the requirement to among files with the same name keep the biggest one might need some scripting. There's a thread here with ideas about how to find duplicates based only on filename, as a start for such a script: https://stackoverflow.com/questions/162 ... ctory-bash

The duplicate searching tools I know are fslint and fdupes (both in the repository) and both have a command line interface (fslint also has a GUI), see information here https://www.pixelbeat.org/fslint/ and here https://github.com/adrianlopezroche/fdupes. I don't know these will do what you want.

I'd suggest to give fdupes a try first and just let it find duplicates in both directories and see if that list what you'd expect (use fdupes -S -r dir1 dir2 to recurse and show filesizes). If the list is short enough just delete by hand perhaps. See its manpage for more options.
Image

rene
Level 13
Level 13
Posts: 4887
Joined: Sun Mar 27, 2016 6:58 pm

Re: command to identify similar filenames

Post by rene »

Déjà Vu: viewtopic.php?f=18&t=266622&hilit=stat#p1456053

That script synchronizes two directories, keeping only the bigger one of same-named files.

User avatar
52ROSt
Level 4
Level 4
Posts: 425
Joined: Mon Apr 14, 2014 10:01 am

Re: command to identify similar filenames

Post by 52ROSt »

viewtopic.php?f=18&t=266622&hilit=stat# ... 3@xenopeek
Moving it to the Scripting Forum is no issue at all. Next time I will go with similar questions to the Scripting Forum.

Thanks for the very usefull fdupes command. I could use it to find out the I only had files with the same name and same size. Lucky me!


@rene
Thanks for the hint with the very interesting bash script. I saved the link for the future

Post Reply

Return to “Scripts & Bash”