LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 04-20-2012, 01:30 PM   #1
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 158

Rep: Reputation: 3
Comparing Directories (diff..?) with its File's Sizes, Ignoring Filenames?


Hello All,

I have 2 directories of mp3s, around about 200+ files or so, in which the mp3s ALL had weird
names after backing them up off my iPod. All the files were named in the format of ABCD.mp3...
I.e. four capital letters with .mp3

I created a Bash script which basically uses the id3tool command to rename the "actual" filenames
to the format of "Artist - Title.mp3". Now some of the files didn't have any information in the id3
tags so I just kept the names the same (i.e. ABCD.mp3). So when I run my script it doesn't do
anything with the original files but creates copies with the new names to a new directory.

Now when I do an "ls -l" on the old and new dirs, I get about a 15 file difference between the old
ones and the new ones. Is there a way to run a diff command (or something similar) and somehow use
awk or something like that to use the file size from "ls -l" command to compare that instead of the names.

I'm positive I could probably whip something up in Perl to do this, but I really want to try this
through the CLI first, because I know there is some powerful commands that can be run that could
take the place of an entire Perl script...

If anyone has any suggestions, or could point me on the right path, that would be great!

Thanks in Advance,
Matt

Last edited by mrm5102; 04-20-2012 at 02:25 PM.
 
Old 04-20-2012, 05:26 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
I think something like
Code:
sdiff <(stat --printf "%s\t%n\n" dir1/*|sort -k1,1n) <(stat --printf "%s\t%n\n" dir2/*|sort -k1,1n)
should get you started...



Cheers,
Tink
 
1 members found this post helpful.
Old 04-23-2012, 09:42 AM   #3
mrm5102
Member
 
Registered: Apr 2011
Location: Philadelphia
Posts: 158

Original Poster
Rep: Reputation: 3
Hey Tinkster, thanks for the reply.

Cool, I'll give that a try and post back what happens...


Thanks Again,
Matt
 
  


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
How to compare timestamp of same file residing in two diff directories prasenjit.patra AIX 1 10-21-2009 05:45 PM
way of ignoring out of order lines in diff? Geneset Linux - Software 2 06-04-2009 11:01 AM
diff / patch ignoring changes to particular lines Kikazaru Linux - General 2 03-09-2009 11:57 AM
How to list the directories of a file system by their sizes? joaotelles Solaris / OpenSolaris 3 12-04-2008 03:11 PM
Comparing file sizes using a bash script. IanChristie Programming 5 12-19-2003 11:14 PM


All times are GMT -5. The time now is 09:10 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration