Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Narpas
Mar 16, 2008
You hear the rumble of distant thunder... You feel that eating the little dog was a bad idea.
I'm trying to use PERL to get rid of duplicate files in a big, big ole directory with similar but different file names. I plan to use the file sizes to differentiate between the different files. For example,

awful 5343.jpg
awful 6064.jpg
something 252.jpg
something 1524.jpg
something 1814.jpg
something 2904.jpg
something 4252.jpg
something 5524.jpg
something 6814.jpg
something 7904.jpg

Where there are only three actually different "something" pictures, and the "awful" pictures are the same. I plan to replace the numbers after the files - those are totally arbitrary - with the file size, so that I get,

awful k10408k.jpg
something k13394.jpg
something k15304.jpg
something k18708.jpg

The loop that I intend to use.
code:
foreach $file (@files) {
	$size = -s "$file" ;                #Problem line - supposed to get the filesize.
	$file =~ /(.*?)\s\d/;               #Get just the name, not the number, of the file
	$filecrop = $1 . " " . $size;       #Put it all together.
	print $filecrop . ".jpg" . "\n";    #This is filler for the file manipulation.
}
The problem is that the line $size = -s "$file"; returns "" for $size. Is there a different way to get the file size, or should I just pass a function to bash?

Narpas fucked around with this message at 23:22 on Mar 22, 2008

Adbot
ADBOT LOVES YOU

Narpas
Mar 16, 2008
You hear the rumble of distant thunder... You feel that eating the little dog was a bad idea.
Well, I knew, academically, about making a hash table, but I didn't realize they were implemented simply - I've always figured that they were needlessly complex for small scale tasks. Also, Sartak - I loved your LP Nethack, assuming that's, in fact, you.

Narpas fucked around with this message at 04:43 on Mar 23, 2008

  • Locked thread