• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: remove icon from picture files
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: remove icon from picture files


  • Subject: Re: remove icon from picture files
  • From: Mads Fog Albrechtslund <email@hidden>
  • Date: Wed, 1 Dec 2010 23:13:11 +0100

Hi Yvan

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).

The original script is from here: http://xahlee.org/perl-python/mac_resource_fork.html
The only part I have change/modified is near the bottom, where I added 3 lines:

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));

utime( $atime, $mtime, $File::Find::name );

These are the ones preserve Timestamps.

Below is the content of the script file.
Save the content in a plain text file, and save it with extension .pl
Use chmod 744 to allow execution.

In Terminal running command:

FullPathToScript FullPathToFolder d

-----------------------------------------------

#! /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.
# For detail, see: http://xahlee.org/perl-python/mac_resource_fork.html

# 2009-05-31, 2009-09-04
# ∑ http://xahlee.org/

# 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

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: remove icon from picture files
      • From: KOENIG Yvan <email@hidden>
References: 
 >remove icon from picture files (From: KOENIG Yvan <email@hidden>)

  • Prev by Date: Re: How to adjust this script to work on Snow Leopard?
  • Next by Date: Re: Working script won't compile
  • Previous by thread: Re: remove icon from picture files
  • Next by thread: Re: remove icon from picture files
  • Index(es):
    • Date
    • Thread