Text Editing Help
-
So I've been editing my 1300 User Preset files to update the names of buttons in a plug-in version update. I've made a mistake and now have two buttons with identical names. I didn't notice in time.
The correct name is on line 107 and the wrong one which I need to change is on line 187 of each preset. Does anyone know of software that can edit only on specific lines?
No joy with Atom and I've been trying Sublime but I'm not that familiar with it....
Thanks!
-
@DanH said in Text Editing Help:
The correct name is on line 107 and the wrong one which I need to change is on line 187 of each preset. Does anyone know of software that can edit only on specific lines?
You can probably do it with Atom/Pulsar or Sublime, but it might not be straightforward. Can you send me the files?
-
@d-healey happily! I'll email you now
-
Got it
-
@DanH If you're comfortable with the command line, this sounds like a job for sed.
sed -i '187s/.*/new text here/' filename
-
@Simon Yeah I think sed is the way to go here, but Dan gave me a little more detail in the email and the text isn't always on line 187.
I think you'd need to modify the command to replace the second instance of Button_SAMPLER_FM_ON with Button_SYNTH_FM_ON in each file. And it needs to search recursively because the presets are organised into subfolders.
-
This post is deleted! -
-
@DanH said in Text Editing Help:
So sed just replaces the whole line?
You can do that or find/replace, up to you.
@DanH said in Text Editing Help:
And what about filename. How do I point it at a file / folder?
You need to use
find
and pass the result to sed. I'm attempting to put an example together for you. -
@Simon Perhaps you can help, my sed foo is failing me.
From what I can tell this should be the correct command on Mac (empty quotes after the
-i
) but it's not working for me. The find works and returns the correct file names, the sed works too, but the combined command doesn't do anything.find . -name "*.preset" -exec sed -i '' "s/Button_SAMPLER_FM_ON/Button_SYNTH_FM_ON/2" {} +
@DanH ChatGPT might also be able to help you here, but make a backup of your presets before trusting it.
-
@d-healey @Simon the Chat has helped! This is the line:
find . -type f -name "*.preset" -exec sed -i '' '187s/Button_SAMPLER_FM_ON/Button_SYNTH_FM_ON/' {} +
I think it's just the quotation marks that are wrong! And it's missing the specified line but nt sure of that's what you were going for. Either way thanks for help guys!
-
@DanH I wasn't specifying the line because you said it could be on either 187 or 188 so I was trying to get it to just always replace the second instance in the file, glad you got a working solution :)