LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-13-2012, 03:37 PM   #1
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Rep: Reputation: 15
Smile Duplicate picutes - move and remane large number of files


Hello all,

I have 2 folders with about 300 pictures in each folder. In both folders there are many pictures that have exactly the same name but actually are different pictures. So far I figure out that if I run fdupes -r command I will be able to list duplicate file names into the file. Now I need to rename all duplicates, maybe moved them to the new folder after I rename them. I was wondering if someone could help with advice on how to do the above?


So far this is what I have in the scripts:

************************************
cd /home/denis/Pictures/

fdupes -r >> /home/denis/Logs/duplicates.txt

************************************

In the output file I have entries like this

/home/denis/Pictures/101MEDIA/IMAG0037.jpg
/home/denis/Pictures/100MEDIA/IMAG0037.jpg

/home/denis/Pictures/101MEDIA/IMAG0113.jpg
/home/denis/Pictures/100MEDIA/IMAG0113.jpg

/home/denis/Pictures/101MEDIA/IMAG0175.jpg
/home/denis/Pictures/100MEDIA/IMAG0175.jpg

and I have about 150 lines like this separated by empty line after every second entry.

Is there a way to run rename command to look into the log file and then to go to the folder and rename every file listed in the second line?

Or any other better solution?

Thank you in advance

smithy2012
 
Old 02-13-2012, 09:08 PM   #2
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
you can use this script I wrote to help you out.It will still leave the duplicates in the original file which you can remove with a oneliner
Quote:
sort file-name | uniq -u
Code:
#!/bin/bash

FILE=testData.txt


sed -n 'n;p;'< "$FILE" >test2Data.txt
sed '/^$/d'<test2Data.txt>test3Data.txt

cat test3Data.txt |
while read ch ;
do
BEGINNING=$(echo $ch | cut -d "." -f 1)

echo "$BEGINNING{.DUP}.jpg"
done

Last edited by cbtshare; 02-13-2012 at 09:15 PM.
 
Old 02-13-2012, 10:27 PM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,974

Rep: Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179Reputation: 3179
You seemed to have provided all data except what you would like to rename the duplicates to? As they are pictures of different things I am guessing adding something like DUP, as suggested
above, will not be much further along than where you are currently?
 
Old 02-15-2012, 11:07 AM   #4
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Original Poster
Rep: Reputation: 15
Hi,

Thank you for your reply, unfortunately I am still not able to rename duplicate files. Your scripts creates additional file and echo list of files on screen however not one file is renamed.
Iam not too much bothered to what to rename the duplicate, prehaps to add one more number or letter at the end of the file name would do the trick.

Cheers

D
 
Old 02-15-2012, 01:11 PM   #5
smithy2010
Member
 
Registered: May 2010
Location: UK
Distribution: OpenSuse 64 bit
Posts: 45

Original Poster
Rep: Reputation: 15
I found software called krename and it did exactely what I wanted, great stuff

:-)

Cheers
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Need help sorting large number of files by timestamp and then greping those files scottjn Linux - Newbie 4 01-14-2011 10:42 AM
ext3 performance -- very large number of files, large filesystems, etc. td3201 Linux - Server 5 11-25-2008 09:28 AM
How to remane a number of files? AGazzaz Linux - General 3 10-01-2006 11:52 AM
Deleting a large number of files msteudel Linux - General 4 01-26-2005 01:36 AM
Large Number of files? mikeshn Linux - Security 2 01-10-2004 06:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:20 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration