Add text before and after a timestamp

Hi all, need some help for this action script.

I have a transcript with timestamps, want to add a same url before all timestamps and add ‘]’ after all timestamps, yeah I try to make timestamps as a markdown link.

eg, ‘00:23:30’ => ‘(timestamp)[https://www.xxxxx.com=’+‘00:23:30’+‘]’ => ‘(timestamp)[https://www.xxxxx.com=00:23:30]’

I tried ‘find and replace’, it looks like not working well.

Thanks for your kind help.

The way you would do that with find and replace would require regular expressions. This example shows what that would look like on the Mac:

(You can do the same on iOS, just need to use “Advanced Find” which you can get to by tapping and holding on the magnifying glass at the top.)

The \d\d:\d\d:\d\d is a regular expression that says to look for three sets of two digits, separated by colons.

The replace value has the \1 to indicate where to insert the value found in a new string.

1 Like

it seems not working, do I need some special settings?

the result for me is ‘(timestamp) [https://www.xxxxx.com=1]’, the original timestamp was replaced by ‘1’.

Only find this post, but my case is more complicated.

I would like an action, first let me input ‘url’,
then find all timestamps,
then combine these strings, ‘[this post](’ + ‘url’ + ‘#=’ + ‘timestamp’ +‘]’,
then replace every timestamps with combined strings.

I try to use GPT to write the script but too difficult for me to adjust the code, could someone help?

Things are a little unclear certainly. In your first post you describe a format for what you want, then make a passing reference to Markdown links (which the format you described was not - look at where the different brackets are). You have switched them around in your latest description, but what Gregg suggested matches against your original example.

So, I think that’s where one problem lies. Check where your square brackets and round brackets (Parentheses) go.

Next, in your replacement, rather than using \1, try using $1 instead as the token for the matched timestamp.

I think that should solve the timestamp being substituted for the character 1.

Hope that helps.

Thanks for your help and sorry for making confuse, yes, I made the mistake. ‘Markdown link’ is what I want.

After changing to ‘$1’, still weird, original timestamps are still replaced.

This is what I want:

‘00:23:30’ => ‘[timestamp] (https://www.xxxxx.com#t=00:23:30)’

using ‘/1’, the result is ‘[timestamp] (https://www.xxxxx.com#t=1)’

using ‘$1’, the result is ‘[timestamp] (https://www.xxxxx.com#t=)’

I’m not in a position to do much testing on this just this moment, but off the top of my head I would try the following replace with the “Use regular expressions” option enabled.

In the find:

\d\d:\d\d:\d\d

In the replace:

[timestamp](https://www.xxxxx.com#t=$1)

Take a backup, give it a try and let us know if that works for you.



the original timestamps are still replaced.

Change the find to:

(\d\d:\d\d:\d\d)

I wasn’t at my Mac and I figured it was an implicit match group … but it wasn’t. The parentheses in the find define the match group.

Before replace all

After replace all

Thanks. It’s working. What magic round brackets!

Drafts saves me a lot time again.