Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Using Automator to replace text inside a file - and batch processing it

Hi,

I wanted to know if this can be done using Automator to replace text inside a file - and batch processing it.

I have over 1750 files that need the same exact word replaced on every one.They are "preset" files for Logic Pro.They are now pointing in the wrong directory username,and I just need to place my username there instead,so the presets work.

The text to be replaced is always the same,and the text to replace with is also the same.I would like it to be a batch process, i.e. I tell Automator the folder/files and it will "automatically" do it.

I tried with scripting,and it's too complicated to even get a file open.And with autoomator...I'm hopeless!!! I could not even figure out how to use the stock actions...I read the manual from top to bottm...but it escapes me how to get it to run,after making a test action.I save the action,and then.....WHAT???

Otherwise I'll have to make all 1750 presets new from scratch...and I'm not about to do that.

Thanks in advance for any help.

Cheers

Caffeine Ultra/Expresso Cards/No Foam, Mac OS X (10.4.8), Wooden Club 1.2/Staffordshire 7.2.3/1902 Horse drawn Cart

Posted on Apr 9, 2007 3:06 PM

Reply
Question marked as Best reply

Posted on Apr 9, 2007 6:56 PM

Yes, it can be done. But not necessarily with Automator alone, you need a tool that can actually process the files, I think Automator is more like a linking framework that links inputs and outputs from different tools and apps together into a workflow, rather than doing any of those detailed tasks itself.

I am not that experienced with AutoMator and AppleScript, but they can be used to select a bunch of files and perform an action on those files, maybe someone can help out with that part.

The basic job you need to perform can be done with the UNIX stream editor, /usr/bin/sed, with a command something like this:

/usr/bin/sed -e 's/oldpath/newpath/g' oldfile > newfile

This will replace all occurences of "oldpath" with "newpath" in the file: oldfile and write the results to the file "newfile"

This could be done in a UNIX script that you run in the Terminal command line, or packaged into an Apple Script that you write in Script Editor.

I hope this helps, and someone else can add some finishing touches or recommend a better approach.
3 replies
Question marked as Best reply

Apr 9, 2007 6:56 PM in response to noeqplease

Yes, it can be done. But not necessarily with Automator alone, you need a tool that can actually process the files, I think Automator is more like a linking framework that links inputs and outputs from different tools and apps together into a workflow, rather than doing any of those detailed tasks itself.

I am not that experienced with AutoMator and AppleScript, but they can be used to select a bunch of files and perform an action on those files, maybe someone can help out with that part.

The basic job you need to perform can be done with the UNIX stream editor, /usr/bin/sed, with a command something like this:

/usr/bin/sed -e 's/oldpath/newpath/g' oldfile > newfile

This will replace all occurences of "oldpath" with "newpath" in the file: oldfile and write the results to the file "newfile"

This could be done in a UNIX script that you run in the Terminal command line, or packaged into an Apple Script that you write in Script Editor.

I hope this helps, and someone else can add some finishing touches or recommend a better approach.

Using Automator to replace text inside a file - and batch processing it

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