I have looked into this.
I have a modified a Perl script, so that it deletes the Resource fork recursively down through a given folder structure.
It preserves the timestamps (Date Created, Date Modified and Last Date opened).
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime);
(($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime) = lstat($File::Find::name));
These are the ones preserve Timestamps.
Below is the content of the script file.
Use chmod 744 to allow execution.
#! /usr/bin/perl -w
# perl
# File name: delete_image_file_resource_fork.pl
# Purpose: Report or delete image files's resource fork of a given dir.
# 2009-05-31, 2009-09-04
# USAGE:
# To list files that have resource fork, do
# perl delete_image_file_resource_fork.pl /Users/xah/Documents/
# To actually delete the resource forks, do
# perl delete_image_file_resource_fork.pl /Users/xah/Documents/ d
# if your path contain space or other chars, you need to quote the path.
# like this
# perl delete_image_file_resource_fork.pl "/Users/xah/Documents/" d
# you can modify the script so that it only checks certain file suffix.
# To do that, go to the body of “wanted” function.
use strict;
use File::Find;
if (not defined $ARGV[0]) {die "Error: argument not received. $0 <dir absolute path> 'd'. If the second argument 'd' is missing, then no deletion will take place, only do report."}
my $path = $ARGV[0];
# should give a full path, not relative path. Else, the $File::Find::dir won't give full path.
my $sizesum=0;
my $filenum=0;
sub wanted {
if (
! -d $File::Find::name &&
-f $File::Find::name &&
$_ =~ m/\.jpg$/i ||
$_ =~ m/\.jpeg$/i ||
$_ =~ m/\.gif$/i ||
$_ =~ m/\.bmp$/i ||
$_ =~ m/\.png$/i
) {
if (-s "$File::Find::name/rsrc" > 0) {
print $File::Find::name, "\n";
$sizesum += -s "$File::Find::name/rsrc";
$filenum++;
if ($ARGV[1] eq 'd') {
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime);
(($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime) = lstat($File::Find::name));
open (FF, ">$File::Find::name/rsrc") or
die "cannot open $!"; close FF;
utime( $atime, $mtime, $File::Find::name );}
}
}
}
find(\&wanted, $path);
print "number of file: $filenum.\n";
print "total size in bytes: $sizesum.\n";
print "Done.\n";
-----------------------------------------------
On 01/12/2010, at 18.22, KOENIG Yvan wrote:
Hello
I have a huge number of picture files with icons which where attached in old time when icons where really small.
I wish to remove these icons.
Of course, I don't want to do that by hand.
I know how to do that with GUI scripting but I'm wondering if there is an other way to remove what is in fact stored in a resource fork.
I thought that I would get a soluce in Satimage but as far as I was able to find, it may put a resource but not remove one :-(
Maybe somebody may give a track.
Yvan KOENIG (VALLAURIS, France) mercredi 1 décembre 2010 18:22:13