Go Back   The macosxhints Forums > OS X Help Requests > UNIX - General



 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 06-16-2003, 07:48 PM   #1
vonleigh
All Star
 
Join Date: Jan 2002
Posts: 579
Finding files by creator code

Hello,

I'm trying to find all files with a certain creator code. I tried googling for a while and since I didn't come up with anything interesting, decided to try and script it.

The problem I'm running into is one of quoting, the find I'm using to generate a list of files gets broken up at the space between files, for example it fails with "Address Book" or the like. I tried looking at find's man page and the only option similar was -X but it's not quite what I need.

Any help is appreciated, here's the script:


Code:
#!/bin/sh

# Find by creator from current dir
list=`find . -type f`

for file in $list
do
code=`GetFileInfo -c "${file}"`

        if [ "$code" == "\"CODE\"" ]
        then
                echo $file
        fi
done

exit 0
Replace CODE with creator code. I'll make it more interactive later with options and submit it, right now I just want it to work.


thanks,
v


Edit:

Here's usage and errors:

Code:
% touch file
% touch "some file"
% SetFile -c CODE file
% SetFile -c CODE some\ file
% ./script
./file
GetFileInfo: could not refer to file (-43)
file
./file is the path to "file", which is the intended output. However "some file" is failing and getting evaluated as "some" and "file" (the second one succeeding btw)

Last edited by vonleigh; 06-16-2003 at 07:53 PM.
vonleigh is offline   Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:09 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.