DonationCoder.com Software > Clipboard Help+Spell
Help creating a custom script to modify format
(1/1)
asrjcb:
I'd like to take a file name with "-" or "_" in between words and replace them with normal spaces. This is caused when I download files from Share Points. But, only after the 2nd occurrence of the string in a standard document naming convention.
Examples:
I want to change "GEN-S-01-How-to-Make-a-Custom-Script" to "GEN-S-01 How to Make a Custom Script"
I want to change "GEN-S-01_How_to_Make_a_Custom_Script" to "GEN-S-01 How to Make a Custom Script"
I'd like to just type it in the Find and Replace, Find field in the Modify Format/Case tool versus making a Custom Script Tool (which I think would be way over my head).
I tried to fool around with regular expressions, but have no experience and failed. Thanks in advance.
mouser:
ok this is a bit convoluted, but should work in CHS:
go to the search and replace tab and you will create 3 entries in this order:
First, a regex one:
Find: ^([^\-\+]+)([\-\_])([^\-\+]+)([\-\_])([^\-\+]+)(.*)$
Replace: $1DASHSEP$3DASHSEP$5$6
Next, a regex one:
Find: [\-\_]
for Replace put a single space
Lastly, a non regex (though shouldnt matter):
Find: DASHSEP
Replace: -
What this does: Changes the first two dashes (or underscores) into the word DASHSEP
Then Replaces all remaining dashes/underscores into spaces
Then puts back the first two dash/underscores with dashes (note that if the first two were an underscore they will change to dash).
screenshot:
Note:
You might still be better off learning to use a simple scripts with CHS because that would allow you to tweak things like this and do more complicated stuff.
IainB:
Ooh! That's a rather a nifty use of CHS, once again showing its potential in ways one might not have intuitively expected. I certainly hadn't really thought about doing something like that with it anyway. Thanks!
:-* CHS :-*
asrjcb:
Wow mouser thanks, it worked perfectly. I'm a huge fan and love Find and Run Robot and CHS. Don't know what I'd do without them. Thanks again.
spam spam bacon spam:
Find: ^([^\-\+]+)([\-\_])([^\-\+]+)([\-\_])([^\-\+]+)(.*)$
Replace: $1DASHSEP$3DASHSEP$5$6
Find: DASHSEP
Replace: -
What this does: Changes the first two dashes (or underscores) into the word DASHSEP
Then puts back the first two dash/underscores with dashes (note that if the first two were an underscore they will change to dash).
-mouser (February 24, 2015, 05:16 PM)
--- End quote ---
Dude.
That was utterly genius!!
Well played, sir. Well played.
~spammage
Navigation
[0] Message Index
Go to full version