Hidden files on flash drives -- can folder actions save the day
My wife has a new flash drive. She wants to use it to put her photos on to get them printed. She copies them from iPhoto. Unfortunately, as you no doubt know, this often results in hidden '._*.jpg' files appearing on the drive. This then confuses many of the photo kiosk machines.
I also use a flash drive for the same purpose. To avoide the problem, I use a program called iCleanup that strips these hidden files. However, that program requires an extra step, and also needs an administrator name and password.
I would like to help my wife by setting up a drop-box folder on the desktop to which she can drag photos from iPhoto. If I can attach a folder action to strip the resource forks, these hidden files should not appear. She could then copy the files to the flash drive with no more hidden files.
Can anyone suggest an applescript or similar that I can attach to the folder? Preferably, it should not require any user intervention apart from putting the files in the folder.
thanks
Adam
I also use a flash drive for the same purpose. To avoide the problem, I use a program called iCleanup that strips these hidden files. However, that program requires an extra step, and also needs an administrator name and password.
I would like to help my wife by setting up a drop-box folder on the desktop to which she can drag photos from iPhoto. If I can attach a folder action to strip the resource forks, these hidden files should not appear. She could then copy the files to the flash drive with no more hidden files.
Can anyone suggest an applescript or similar that I can attach to the folder? Preferably, it should not require any user intervention apart from putting the files in the folder.
thanks
Adam
Comments
EDIT: If you can say what the nature of these files is, it should be straightforward to put together a Folder Action script. This can also be done with some shell scripting using the new "launchd" feature in Tiger.
Have you tried disabling the "._" files through Tinkertool? I've tried it myself before on Windows network drives, never got it to work. But in theory it should, so you might want to give it a try.
http://www.macupdate.com/info.php/id/5721
Edit: Just saw it's just for .DS_store files.. No, you're gonna have to strip those resource forks...
.DS_Store files are not a problem as they do not show up as JPGs on the photo kiosks. The system preference in tinkertool to turn off .DS_Store only applies to network volumes, not local removable drives.
If I could set up a way to force the creation of separate resource fork files on a HFS+ volume, I could script to delete them, but they don't appear until copied to the flash drive.
I will try to work out how I can attach a folder action to a FAT flash drive itself to delete them. Any advice would be appreciated.
I note that a program called Blue Harvest does what I need done, but it installs as a system preference item and runs in the background. It is also $10. I would prefer a different solution.
thanks
First, try this to see if we are getting the result we need:
Step 1: make 2 folders on the Desktop, DropFolder and StrippedFolder.
Step 2: Drag some iPhotos into DropFolder.
Step 3: Execute the following in Terminal; notice the space after the asterisk:
cp ~/Desktop/DropFolder/* ~/Desktop/StrippedFolder/
That should strip off the resource forks. Now drag the files in StrippedFolder to the flash drive and take a look at it to see if the dot-files are not there.
If this worked, then a 5-line AppleScript will do the trick.
Can anyone confirm the effect of cp in Tiger?
Originally posted by adamr
This seems to work on Panther, but I had heard the Tiger version of cp does copy resource forks. My main machine is on Tiger, but I just put it in to be serviced. I can't test myself.
Can anyone confirm the effect of cp in Tiger?
I've got Tiger, but no FAT volume to check. Lemme see if there is a utility to look for resource forks... actually I think it is called lsmac.
EDIT: I checked with lsmac and the resource fork remains when using cp - so that isn't going to work.
Need a BSD utility to strip resource forks - should be easy to find, I will look.
Dual-G5:~/Desktop lundy$ lsmac -frsrc Unstripped/
...
------ JPEG ogle 0 B IMG_0003.jpg
------ JPEG ogle 0 B IMG_0004.jpg
------ JPEG ogle 0 B IMG_0008.jpg
------ JPEG ogle 0 B IMG_0009.jpg
-C---- 51.3 KB IMG_0011.jpg
-C---- 53.4 KB IMG_0024.jpg
-C---- 56.2 KB IMG_0032.jpg
-C---- 56.7 KB IMG_0082.jpg
-C---- 56.2 KB IMG_0083.jpg
-C---- 56.5 KB IMG_0084.jpg
-C---- 52.5 KB IMG_0145.jpg
-C---- 52.6 KB IMG_0147.jpg
-C---- 52.6 KB IMG_0148.jpg
...
----------------------------------------------
2.3 MB Total Size of Files in Folder
Dual-G5:~/Desktop lundy$ ditto --norsrc Unstripped/ Stripped/
Dual-G5:~/Desktop lundy$ lsmac -frsrc Stripped/
------ 0 B IMG_0003.jpg
------ 0 B IMG_0004.jpg
------ 0 B IMG_0008.jpg
------ 0 B IMG_0009.jpg
------ 0 B IMG_0011.jpg
------ 0 B IMG_0024.jpg
------ 0 B IMG_0032.jpg
------ 0 B IMG_0082.jpg
------ 0 B IMG_0083.jpg
------ 0 B IMG_0084.jpg
------ 0 B IMG_0145.jpg
------ 0 B IMG_0147.jpg
------ 0 B IMG_0148.jpg
----------------------------------------------
0 B Total Size of Files in Folder
Dual-G5:~/Desktop lundy$
So it's a simple matter of a folder action that uses "do shell script" to execute the ditto --norsrc command. That would run ditto every time anything is added to the folder, repeating the copy unnecessarily. So we could also set the folder action to strip and then delete the originals - they are still in iPhoto, after all.
EDIT: This resource-stripping with ditto is blazing-fast using the folder watch path feature of Tiger's new launchd architecture. I just set up a watch folder in launchd's plist and it took about a half a second to copy and strip all of 70+ files from the watched folder into another.
That way you can avoid Applescript Folder Actions completely, and with launchd it is much easier to set up and remove. I'll show you how to implement it once I get the particulars of your setup.
First, create the two folders on the Desktop. I will call them PhotoDropBox and StrippedPhotos.
Second, if there is no folder in /Users/Youracct/Library called LaunchAgents, create that folder there.
Next, write the script:
1. Make a new TextEdit document.
2. Choose "Make Plain Text" from the Format menu.
3. Copy and paste these lines into the document:
#! /bin/bash
echo $(date) "StripResourceForks begun." >>/dev/console
ditto -V --norsrc ~/Desktop/PhotoDropBox/ ~/Desktop/StrippedPhotos/
rm ~/Desktop/PhotoDropBox/*
echo $(date) "StripResourceForks completed." >>/dev/console
Next, save the script from TextEdit to the /Users/Youracct/Library/Scripts folder. Give it the name StripResourceForks (TextEdit will add the ".txt" extension).
In Terminal, make the script file executable:
chmod +x ~/Library/Scripts/StripResourceForks.txt
Next, download Lingon from sourceforge.net:
http://lingon.sourceforge.net/
This is a utility that makes configuring a launchd folder watch a breeze.
Launch Lingon and set the following:
1. From File, select New.
2. Click the "My Agents" button in the dialog box. Click Create.
3. In the Basic tab of the next dialog, type a label: com.adamr.stripresourceforks would be fine (any name that is unique is OK)
4. Check the "On Demand" checkbox.
5. In the "Program" text box, type "/Users/Youracct/Library/Scripts/StripResourceForks.txt", without quotes and substituting your Home folder name for "Youracct".
6. Click the Paths tab at the top of the window.
7. In the WatchPaths box, type /Users/Youracct/Desktop/PhotoDropBox .
8. Click the Save and Reload button at the bottom.
9. For good measure, click Reload and then quit Lingon.
That's it. You now have a plist file in your Library/LaunchAgents folder that tells launchd to watch the folder PhotoDropBox on the Desktop and to run the script ~/Library/Scripts/StripResourceForks.txt whenever items are added to that folder. The script ~/Library/Scripts/StripResourceForks.txt will use the ditto command to strip the resource forks for all files that are in the folder, move the stripped files to the StrippedPhotos folder, and then delete all of the files in the PhotoDropBox folder.
Drop some photos into PhotoDropBox and make sure that they get moved to the StrippedPhotos folder. If they don't, post here.
I hadn't had a chance to follow your execellent suggestions over the weekend. I will do so tonight and let you know.
I wasn't aware of the launchd thing. I thought it would need to be with folder actions.
I will also try to sort out a script to check whether the flash drive is present and, if so, copy directly to it.
Cheers
Adam
Originally posted by adamr
Sorry, Lundy
I hadn't had a chance to follow your execellent suggestions over the weekend. I will do so tonight and let you know.
I wasn't aware of the launchd thing. I thought it would need to be with folder actions.
I will also try to sort out a script to check whether the flash drive is present and, if so, copy directly to it.
Cheers
Adam
OK - thanks for your reply. I tested the above launchd agent and it works fine for stripping the resource forks.
Now the way I would do the transfers is leave the above launchd agent in place, so that all files dropped into the folder are stripped and placed in the second folder. Then here is a second launchd agent that you would use to detect when the flash drive is plugged in:
Make another launchd agent with Lingon, except this time set the watched folder to /Volumes . This will trigger the agent when anything is added to /Volumes, meaning when any drive is plugged in or mounted (including iPods, firewire drives, etc).
Instead of the shell script that does the "ditto" command as above, use the following bash shell script:
#! /bin/bash
# Script that executes anytime item(s) are added to the /Volumes directory
# e.g. when the FlashDrive, iPod, or other drive is plugged in
#
# Replace 'FlashDrive' with the name of the USB flash drive that is used.
#
# Check if the drive that was mounted is in fact the Flash drive - otherwise ignore.
# If it is the flash drive, copy the processed photo files to the flash drive and
# delete them from the folder on the desktop.
#
if [ -d "/Volumes/FlashDrive" ]
then
ditto --norsrc ~/Desktop/StrippedPhotos/ /Volumes/FlashDrive/
rm ~/Desktop/StrippedPhotos/*
fi
Again, to make the script, set TextEdit to Plain Text, save the script to ~/Library/Scripts, execute chmod +x, and type its path into the box next to Program in Lingon,
e.g.
chmod +x ~/Library/Scripts/CopyToFlash.txt
This combo of 2 scripts together will
1. Automatically prepare the files for moving to the flash drive, as they are dropped
and
2. Automatically transfer over to the flash drive all de-resourced files when the flash drive is plugged in.
You will have to change the pathnames in the script to correspond to the actual name of the flash drive and any folder on it that you want to specify. You can also delete the line that empties the folder of processed files, but that would mean that the script will copy them over to the flash drive again when it is re-inserted.
HOWEVER, as I found, some of you who try the launchd agent method described above may have some problems with it, so you may have to do something a little different to make it work.
I wasn't able to use the launchd folder watching method to make stripping the resource forks automatic, as I would usually end up with a "StrippedPhotos" folder full of 0 KB files, along with an error message that would be thrown during the processing that "process could not be completed because some of the required items could not be found," although the script was apparently processing all the files, since I ended up with the proper number of files in the StrippedPhotos folder, even though none of them had any data.
Even copying the files one or two at a time into the PhotoDropBox folder would result in one or two 0 KB files in the StrippedPhotos folder and the error message more than half the time, although SOMETIMES it would work, so apparently something minor was throwing things off.
What was APPARENTLY happening (I don't know enough about the techie behind-the-scenes stuff to know for sure) was that the stripping process was so fast that the Finder could not copy the files into the PhotoDropBox folder (from an external drive) fast enough to keep up. My guess is that as a result, instead of processing the actual copied files, the StripResourceForks script was processing the placeholders that Finder seems to put in the destination folder at the beginning of the copy process, which were then being deleted by the script before the Finder was finished copying, resulting in the "process could not be completed ..." error message being generated by Finder. Because the script was processing the placeholders instead of the actual copies, the result was a file in the StrippedPhotos folder with neither a resource fork nor any data. (someone who knows more about this might want to clarify what is REALLY happening, if necessary)
I solved the problem by starting Lingon again, selecting the "com.adamr.stripresourceforks" agent in the "My Agents" tab, clicking the "Unload" button, deleting the agent, then quitting Lingon. This deletes the launchd folder watch configuration, so the process will no longer occur automatically when the photos are copied into the PhotoDropBox folder. However, the "StripResourceForks.txt" script can still be executed manually using the script menu in the menu bar.
Now, although I have to use the "StripResourceForks.txt" script manually after copying my files into the PhotoDropBox folder, it works perfectly every time. The photos are copied into the StrippedPhotos folder without resource forks and the originals are then deleted from the PhotoDropBox, and I can then copy the stripped photos to my SD card without those pesky "._*.jpg" files showing up.
A LITTLE less convenient, but seems to be a LOT more reliable! :-)
The volume for “IMG_0082.JPG” cannot be found.
My wife took hundred pictures on vacation. Cannon Camera. Loaded them in a Verbatum flash drive to give to me. I copied the pictures to my MAC Air.
the thumbnails in the file are OK but when I make the pictures full size I get the above message for all the pictures. I am a old PC user who has conveted to Apple YAAAAAAY. But pretty geeky.
I read through the posts and only understood 20% BUT I got the jist that copying directly from the camera disk to a flash drive doesn't add some pertinent information the AIR needs. ???
I deleted the copied photos from Iphoto library. I copied the camera file found on the flash drive onto another flash drive, (on a PC), I then copied the second flash copy to the Air
YAAAAAY WORKED! NO MORE ERROR MESSAGES. In the process I found this forum. Cool.
EDIT: If you can say what the nature of these files is, it should be straightforward to put together a Folder Action script. This can also be done with some shell scripting using the new "launchd" feature in Tiger.
Cheap Moncler Jackets
Women Moncler Coat
Moncler Kids Jacket
Moncler VestThis deletes the launchd folder watch configuration, so the process will no longer occur automatically when the photos are copied into the PhotoDropBox folder. However, the "StripResourceForks.txt" script can still be executed manually using the script menu in the menu bar.