Automator to process new files
Wondering in anyone can help me out here or point me where to look.
I have files that are created by windows (in a VM on my Mac) - which I then email using Apple Mail to folks using Outlook on Windows - in the process the windows CR LF gets converted into a double CR (or something that results in effectively a double CR).
I have a terminal command that works:
for f in *csv; do sed 's/^M//' $f > $f.new && mv $f.new $f; done
and have found apps that can do the same thing - with user intervention.
But what I really want to do is setup an Automator folder action that will run the command for me.
I thought I was close with something along the lines of this:
Find Finder Items - where file extension is .csv
pass as arguments to shell script
with
for f in "$@"; do sed 's/^M//' $f > $f.new && mv $f.new $f; done
but that does not seem to do it. not sure if maybe the ^M is not getting parsed correctly - when typing that in the command line you hvae to type ctrl-V then ctrl-M to get it to show properly. maybe there is some other sed parameters that woudl work.
Overall - I would like any new file csv file created in my working folder to have a conversion run on it such that emailing it doesn't result in extra lines.
Or another option that may work is a folder action that triggers an Applescript to open each new csv in MS Excell on the Mac and then save and close it - that appears to correct the eol issue such that Mail does not "corrupt" the files.
MacBook Pro, Mac OS X (10.7.3), iPhone 4s 64GB iPad 16GB