• 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: How to detect a file has resource fork, or not?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to detect a file has resource fork, or not?


  • Subject: Re: How to detect a file has resource fork, or not?
  • From: Chris Janton <email@hidden>
  • Date: Tue, 16 Mar 2004 02:36:05 -0700

here's a shell-based test

set f to choose file
set res_path to quoted form of POSIX path of f & "/..namedfork/rsrc"
set byte_count_str to do shell script "cat " & res_path & " | wc -c"

if byte_count_str as number is greater than 0 then
-- resource fork is non-empty
end if

warning - gratuitous use of "cat"

You can simply state the above command as

"wc -c " & res_path

no need to cat the file into a pipe - wc will read it just fine.

Now for a "simpler" shell based test for an empty file

try
do shell script "test -s ~/foo/..namedfork/rsrc"
on error errMsg number errNum
{errMsg, errNum}
end try

"test -s" returns true if a file exists *and* has a size greater than 0

The "test" command (and its friend in the shell "[ expression ]" ) is well worth a look-see in the man pages.

8)
----------------------------------
Chris Janton - face at CentosPrime dot COM
Netminder for Opus1.COM
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: How to detect a file has resource fork, or not?
      • From: steve harley <email@hidden>
  • Prev by Date: Sending data direct to USB in OSX
  • Next by Date: Re: applescript to get system version
  • Previous by thread: Re: How to detect a file has resource fork, or not?
  • Next by thread: Re: How to detect a file has resource fork, or not?
  • Index(es):
    • Date
    • Thread