Go Back   The macosxhints Forums > OS X Help Requests > System



Reply
 
Thread Tools Rating: Thread Rating: 7 votes, 5.00 average. Display Modes
Old 02-16-2006, 12:31 PM   #21
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
Grrr... it happened again, two at once this time.

I downloaded Watchfile.

Quote:
Perl script ... that prints a message when one of the specified files gets modified. As usual, you need to make the script file executable (with chmod +x) and install the script in a folder that is in your shell's execution path.

I don't know how to do this. In fact I can't find any invisible files that include "icon" in the name using Spotlight.

Quote:
Custom icons are stored in a file named exactly Icon which has it's invisibility flag set. These files are in the same directory as the item with the custom icon. -- Trevor

Some of the files that lose their icons are stored in Documents/Games Upstairs/Psychic Game. Their are 5 files in there all with the same custom icon.

Then...
Quote:
You execute this script in a Terminal window, specifying the file or files you want it to watch in the usual way (a space-separated list of filenames). For example ... % watchfile ~/Library/Preferences/com.apple.finder.plist

i.e.: % watchfile ~/Documents/Games Upstairs/Psychic Game.* (right?)

Do I need to keep Terminal open for this to write to?

Quote:
The script will print a message "info stored" when it starts watching each file and then it will check on the file each 10 seconds after that and print a message if anything about the file has changed.

And where in the syntax do I append the "/a" for a beep?

As you can see I will need some detailed help notes to track this puppy. But that sound like the right way to proceed.
avalon is offline   Reply With Quote
Old 02-16-2006, 12:37 PM   #22
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
The 2 files that lost icons are the 2 Excel files I was using last before shutting down. I remember that when I quit Excel I did a Save All rather than saving both individually before choosing Quit. In case that data spurs any imaginations.
avalon is offline   Reply With Quote
Old 02-16-2006, 12:49 PM   #23
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by avalon
I don't know how to do this. In fact I can't find any invisible files that include "icon" in the name using Spotlight.

You don't want to use Spotlight for this.
You need to use Terminal. Read at least the first section of this Unix FAQ
Also read the section on navigating and listing folder contents.
There's no point in going further if you haven't located these "Icon" files.

Quote:
% watchfile ~/Documents/Games Upstairs/Psychic Game.* (right?)

Not quite.
First off, since there are spaces in some of the folder names, you'll need to put the path inside quotes - see the Unix FAQ. And thus it would be best to use /Users/your_username instead of ~

Is "Psychic Game" the name of a folder?
If so, you want the last part to be "/*" instead of ".*":
watchfile "/Users/your_username/Documents/Games Upstairs/Psychic Game/"*
Test this out with the 'ls' command first.
Doing something like:
ls "/Users/your_username/Documents/Games Upstairs/Psychic Game/"*
should list the files you want.

Quote:
Do I need to keep Terminal open for this to write to?

Yes

Quote:
And where in the syntax do I append the "/a" for a beep?

Immediately after the line that says:
print_msg($filename, "Changed: $mods", 1);
you could add a new line:
print "\a"; # make a beep
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 12:52 PM   #24
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by avalon
The 2 files that lost icons are the 2 Excel files I was using last before shutting down. I remember that when I quit Excel I did a Save All rather than saving both individually before choosing Quit. In case that data spurs any imaginations.

Well, you should immediately try this experiment again.
Save an Excel file that has a custom icon.
Does the icon get lost upon restart?
Then open a few Excel files that have custom icons and do Save All.
Do the files get lost upon restart?
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 02:05 PM   #25
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
Quote:
ls "/Users/your_username/Documents/Games Upstairs/Psychic Game/"*


Here's the input/output from my terminal command. I've highlighted some things to make asking a few questions easier.


Last login: Thu Feb 16 13:11:42 on console
Welcome to Darwin!
Upstairs-Computer:~ robertkinleyjohnson$ ls "/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/"*
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of Campus Mapped
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of The Houses
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of mapping the campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of re-mapping the campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of re-re- mapping campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of re-re-re mapping camp
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of victorian plans sorti
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Backup of ??? Psychic Game-Player
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Berkley Mapping.xls
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Berkley Maps Workbook.xls
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Berkley.xls
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Campus Mapped
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Icon?
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/James' Settite Possibility
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/The Houses
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/The Houses Top Elevation
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/The Houses copy
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Workbook1.xls
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/making the little buildings
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/mapping the campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/mapping the campus copy
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/re-mapping the campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/re-re- mapping campus
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/re-re-re mapping campus copy
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/victorian plans sorting
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/??? Psychic Game-Player Notes
/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/??? Psychic Game-Player Notes copy
Upstairs-Computer:~ robertkinleyjohnson$



3 colors, 3 questions so you can see what I am and am not grasping.

ls "/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/"*

From reading the section on navigating and listing folder contents*, I would have thought this syntax would have been more like:
ls /Users/robertkinleyjohnson/Documents/"Games Upstairs"/"Psychic Game"/*


/Users/robertkinleyjohnson/Documents/Games Upstairs/Psychic Game/Icon?

Why is there only 1 "Icon" file when several of these files have custom icons, albeit all the same custom icon? And I was not expecting "Icon" with a question mark; does that mean something is wrong?


??? Psychic Game-Player Notes
??? Psychic Game-Player Notes copy

The 3 ?'s here correspond to "•" in the file names: • Psychic Game-Player Notes copy. I bet these ?'s are not related to the Icon question mark. Right?
avalon is offline   Reply With Quote
Old 02-16-2006, 02:10 PM   #26
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
Here's the current data on the save vs. save all.

Just now, opening 1 file, changing something, saving. The icon was ok. Restart, no icon.

Opening 2 files, changing/saving, quitting, save all, no icons before even restarting.

I need more data to overcome the small sample size but so far any pattern with last night's save all seem contradictory.
avalon is offline   Reply With Quote
Old 02-16-2006, 02:14 PM   #27
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by avalon
From reading the section on navigating and listing folder contents*, I would have thought this syntax would have been more like:
ls /Users/robertkinleyjohnson/Documents/"Games Upstairs"/"Psychic Game"/*

There are often lots of variations that will work.

Quote:
Why is there only 1 "Icon" file when several of these files have custom icons, albeit all the same custom icon? And I was not expecting "Icon" with a question mark

I think that one file contains all of the custom icons for files in that folder.
The question mark in its name is because the name of the file has 5 characters - the last character is (if I recall correctly) a "\r" character - something that doesn't display properly. This is normal.

Quote:
The 3 ?'s here correspond to "•" in the file names: • Psychic Game-Player Notes copy. I bet these ?'s are not related to the Icon question mark. Right?

Right
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 02:17 PM   #28
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Due to what I pointed out above about the one "Icon\r" file per folder, it is probably best if you do your troubleshooting experiments with folders that have only one file that has a custom icon.
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 02:31 PM   #29
frankko
All Star
 
Join Date: Jan 2002
Location: New York, NY
Posts: 587
I don't think that's true about the "Icon?" file being for all custom icons for files within that folder; it's just the custom icon for the folder itself. A folder can't have a resource fork, right, so there would be no other place to put its icon, like how a volume's icon is located in a file called .VolumeIcon.icns at the volume's root.

If you paste a custom icon onto a folder (a folder containing a file with its own custom icon), then you delete the newly created "Icon?", the custom icon for the file will remain, while the custom icon for the folder will be gone.
frankko is offline   Reply With Quote
Old 02-16-2006, 02:43 PM   #30
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
Quote:
Due to what I pointed out above about the one "Icon\r" file per folder, it is probably best if you do your troubleshooting experiments with folders that have only one file that has a custom icon.

Good point.

Quote:
I think that one file contains all of the custom icons for files in that folder.

Seems likely. I just did ls on a folder with 2 different custom icons. It only listed the 1 "icon?"

I have created a new sub-folder in the Psychic Game folder and placed an experimental copy of one of the custom iconned Excel files.

So if I am right my filepath should be:
/Users/robertkinleyjohnson/Documents/"Games Upstairs"/"Psychic Game"/"Terminal Icon Testing"/*
Right?

Now where should I put the (Watchfile) script in a folder that is in your shell's execution path?

And how do I make the (Watchfile) script file executable (with chmod +x)?
avalon is offline   Reply With Quote
Old 02-16-2006, 02:58 PM   #31
bramley
MVP
 
Join Date: Apr 2004
Location: Cumbria, UK
Posts: 2,461
I agree with Franko - I don't get Icon files when the file icon is changed.

If I change a file icon the file modification date is altered, although its size remains constant. I thought custom icons were stored in the resource fork - although I don't understand why my file sizes remain constant. Does the 'ls' command only show the size of the data fork?

I don't know an answer - but is there some reason why Avalon can't have resource forks? Which would explain why the icons go.

Last edited by bramley; 02-16-2006 at 03:47 PM.
bramley is offline   Reply With Quote
Old 02-16-2006, 03:29 PM   #32
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
On my second (downstairs) computer running 10.2.8 I am not having these problems. But when I experiment with a new folder and the ls command, I get interesting results.

I start with an empty folder with no special icon. ls to that folder lists nothing. I put an icon on it and ls lists "icon?" I remove the icon and ls still says icon.

Start over with a new folder. no icon. add a file with no custom icon. ls sees file, mentions no icon. Add custom icon to file, ls still lists no icon with the file.

So where do we think the custom icons for nonfolder file items live? I have of course no idea.
avalon is offline   Reply With Quote
Old 02-16-2006, 03:38 PM   #33
frankko
All Star
 
Join Date: Jan 2002
Location: New York, NY
Posts: 587
Quote:
Originally Posted by avalon
I remove the icon and ls still says icon.

Remove the icon how? By rm'ing the Icon? file in Terminal or getting info on the file and hitting Delete on the keyboard? Because I noticed a difference between the two methods, too. My only guess would be that, in the latter case, rather than just delete the custom icon file, the OS just places the "generic" icon in the Icon? file.

Quote:
Originally Posted by avalon
Start over with a new folder. no icon. add a file with no custom icon. ls sees file, mentions no icon. Add custom icon to file, ls still lists no icon with the file.

File icons are stored in their resource fork. Those aren't visible via ls (not by just doing `ls`, anyway; there might be a way to show them using a flag, but I don't know).
frankko is offline   Reply With Quote
Old 02-16-2006, 04:03 PM   #34
bramley
MVP
 
Join Date: Apr 2004
Location: Cumbria, UK
Posts: 2,461
A resource fork can be displayed with ls by typing

"ls -l foobar.extension/rsrc"

The command works on one file only.

I don't know if watchfile can be made to watch the resource fork in the same way as for an 'ordinary file.' Maybe Avalon could try and see.
bramley is offline   Reply With Quote
Old 02-16-2006, 04:06 PM   #35
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by frankko
I don't think that's true about the "Icon?" file being for all custom icons for files within that folder; it's just the custom icon for the folder itself. A folder can't have a resource fork, right, so there would be no other place to put its icon, like how a volume's icon is located in a file called .VolumeIcon.icns at the volume's root.

If you paste a custom icon onto a folder (a folder containing a file with its own custom icon), then you delete the newly created "Icon?", the custom icon for the file will remain, while the custom icon for the folder will be gone.

Okay, I stand corrected. What I said was partly just a guess, partly a vague recollection. What you say makes more sense (as well as being empirically verified )
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 04:10 PM   #36
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by bramley
A resource fork can be displayed with ls by typing

"ls -l foobar.extension/rsrc"

Although that works, I recall reading that that method is now deprecated and the "correct" method is:

ls -l foobar.extension/..namedfork/rsrc
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 04:19 PM   #37
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by bramley
I don't know if watchfile can be made to watch the resource fork in the same way as for an 'ordinary file.'

Yes - I just tried using 'watchfile' on a resource fork and it works fine:
Code:
% watchfile ~/Junk/Test/foo.html/..namedfork/rsrc
Thu Feb 16 16:13:24 2006: /Users/fred/Junk/Test/foo.html/..namedfork/rsrc: info stored
-rw-r--r--   1 fred  fred  49128 Feb 10 08:56 /Users/fred/Junk/Test/foo.html/..namedfork/rsrc

# (in another Terminal window): cp /dev/null foo.html/..namedfork/rsrc

Thu Feb 16 16:13:44 2006: /Users/fred/Junk/Test/foo.html/..namedfork/rsrc: Changed: size mtime ctime 
-rw-r--r--   1 fred  fred  0 Feb 16 16:13 /Users/fred/Junk/Test/foo.html/..namedfork/rsrc
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 02-16-2006, 04:41 PM   #38
bramley
MVP
 
Join Date: Apr 2004
Location: Cumbria, UK
Posts: 2,461
Quote:
Originally Posted by hayne
Although that works, I recall reading that that method is now deprecated and the "correct" method is:

ls -l foobar.extension/..namedfork/rsrc

I was going to say that I've just noticed plenty of whining system.log messages saying 'foobar.extension/rsrc' is depreciated.
bramley is offline   Reply With Quote
Old 02-16-2006, 05:00 PM   #39
avalon
Triple-A Player
 
Join Date: Oct 2005
Posts: 179
I stepped out to buy groceries. I'll answer several posts at once.

Quote:
Remove the icon how? By rm'ing the Icon? file in Terminal or getting info on the file and hitting Delete on the keyboard? Because I noticed a difference between the two methods, too. My only guess would be that, in the latter case, rather than just delete the custom icon file, the OS just places the "generic" icon in the Icon? file. -- Frankko

I used the Get Info cut method to restore the default. My guess is that unless the system is specifically told to clean up the old file that it will remain. I suspect rather than putting the default icon in the icon file and effectively making it a custom icon, that there is a flag or when the system accesses and find the file blank that it puts in the default as a true default. But it doesn't actually matter.

Quote:
Although that works, I recall reading that that method is now deprecated and the "correct" method is: ls -l foobar.extension/..namedfork/rsrc --hayne

Since I'm just learning I'm all for learning the "correct" ways. I have to say I dislike that in something that seems as Assembler language-like as Unix/Terminal does, that "there are often lots of variations that will work." As Hayne said comparing ls /Users/robertkinleyjohnson/Documents/"Games Upstairs"/"Psychic Game"/* to the syntax ls "/Users/your_username/Documents/Games Upstairs/Psychic Game/"*. But that's just me.

So, um, I use ls -l foobar.extension/..namedfork/rsrc to find the path of the custom icon's fork.... How?

ls -l foobar.extension/users/kinleyjohnson/robertkinleyjohnson/documents/"Games Folder"/"Psychic Game"/"Terminal Icon Testing"/name_of_excel_file/rsrc?

Then after you correct on what I typed above, back to my previous ignorances:
Where should I put the (Watchfile) script in a folder that is in your shell's execution path?

And how do I make the (Watchfile) script file executable (with chmod +x)?


Thanks for everyone's help.
avalon is offline   Reply With Quote
Old 02-16-2006, 11:41 PM   #40
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 32,473
Quote:
Originally Posted by avalon
ls -l foobar.extension/users/kinleyjohnson/robertkinleyjohnson/documents/"Games Folder"/"Psychic Game"/"Terminal Icon Testing"/name_of_excel_file/rsrc?

No - it would be more like:
ls -l /Users/kinleyjohnson/robertkinleyjohnson/Documents/"Games Folder"/"Psychic Game"/"Terminal Icon Testing"/name_of_excel_file/..namedfork/rsrc

Quote:
Then after you correct on what I typed above, back to my previous ignorances:
Where should I put the (Watchfile) script in a folder that is in your shell's execution path?

And how do I make the (Watchfile) script file executable (with chmod +x)?

These questions are answered in the Unix FAQ referred to above.
E.g. make a new folder under your home folder and call it something like "Scripts" (or whatever you like) and then follow the directions in the FAQ to make your PATH include that folder.
Or just don't worry about the PATH variable for the moment and just use the full pathname when you run the script.
E.g. if it is called "watchfile" and is in a folder named "Scripts" under your home folder, you can run it with the full path:
~/Scripts/watchfile
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Reply


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 11:18 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, 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.