Folder Action to run a shell script

Hi,


I want to create a Folder Action to run the following shell script on all files with extension .vcs:


sed '1d' >reminder.ics


The job of the Folder Action is to take any Calendar item files downloaded from TVGuide.co.uk, remove the first line and then save them as .ics files. The reason for this is that the files are automatically generated with a carriage return on the first line, which BusyCal (being strict about these things) doesn't like. It then rejects the whole file.


I have tried doing this with Automator but the result didn't work.


If it's possible to have the Folder Action retain the original file name (ie. everything pre-extension) that'd be a bonus.


Many thanks.

Mac mini (Mid 2011), Mac OS X (10.7.4)

Posted on Jun 14, 2012 12:38 PM

Reply
4 replies

Jun 14, 2012 2:27 PM in response to Scotch_Brawth

I don't understand. If you create the folder action as a shell script you are given the pathnames of all the files dropped/added into the target folder so you have all the information you need to manipulate the filenames.


For example, I created the following test folder action:


User uploaded file


I dropped three files in to the testf folder and it created a list of three pathnames in /tmp/x. That's all you need to do any name manipulations you want.

Aug 7, 2012 1:00 PM in response to X423424X

Hey X423424X...


Would you mind sharing how you got to your screenshot? I'm trying to do the same basic thing.


1) Watch a folder for changes.

2) Pass a list of files to an image compression tool called ImageOptim (open -a ImageOptim.app filename [filename filename].


I see how to attach a folder action in general but I'm not seeing how to tie this in to your shell script example.

Aug 12, 2012 12:47 PM in response to X423424X

@X423424X: So sorry, email notifications weren't turned on for this thread :facepalm:


I don't know what I tried before asking for help here, but whatever it was, it didn't work. I've used your advice and screenshot however and managed to use the Shell Script function to do what I want, and now have a fully tested and functioning script to remove that annoying extra line.


Thanks 🙂

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Folder Action to run a shell script

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.