# \[TikTok, MKV\] Replace part of URL using value from a Field?

**URL:** <https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958>\
**Category:** Support\
**Created:** [January 19, 2022, 8:00pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958 "2022-01-19T20:00:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wakaku](https://community.mp3tag.de/user_avatar/community.mp3tag.de/wakaku/32/6418_2.png) [@Wakaku](https://community.mp3tag.de/u/Wakaku)\
**Post date:** [January 19, 2022, 8:00pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/1 "2022-01-19T20:00:48Z")

</div>

Hello. For TikTok videos, I have a specific field/MKV tag, `UPLOADER_ID`, which is the true _numeric_ username, say `01234567890`.

So `UPLOADER_ID` = `01234567890`

The `URL` tag would be for example:

```auto
https://www.tiktok.com/@usernameABC/video/1234567890
https://www.tiktok.com/@usernameXYZ/video/0987654321

```

If possible I would like to replace the part of the `URL` tag after the `@` sign, so from the example above are `usernameABC` and `usernameXYZ` to be replaced by the whatever value from the `UPLOADER_ID` tag.

So after replacement, it would be like:

```auto
https://www.tiktok.com/@01234567890/video/1234567890
https://www.tiktok.com/@01234567890/video/0987654321

```

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [January 19, 2022, 8:14pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/2 "2022-01-19T20:14:27Z")

</div>

I tried this:  
`$regexp('https://www.tiktok.com/@usernameABC/video/1234567890','(.*)/@(.*)/video/.*',$1/@%UPLOADER_ID%/video/%UPLOADER_ID%)`  
naturally replace the complete URL string with the field name where you find that data.

> [@Wakaku](#):
>
> So after replacement, it would be like:  
> [TikTok - Make Your Day](https://www.tiktok.com/@01234567890/video/1234567890)  
> [TikTok - Make Your Day](https://www.tiktok.com/@01234567890/video/0987654321)
> 
> ```auto
> 
> ```

I think the second example is not quite correct. It should be  
`https://www.tiktok.com/@0987654321/video/0987654321`

Or if I misunderstood that:  
`$regexp('https://www.tiktok.com/@usernameABC/video/1234567890','(.*)/video/.*',$1/video/%UPLOADER_ID%)`

---

<div class="post-metadata">

**Author:** ![Wakaku](https://community.mp3tag.de/user_avatar/community.mp3tag.de/wakaku/32/6418_2.png) [@Wakaku](https://community.mp3tag.de/u/Wakaku)\
**Post date:** [April 6, 2022, 2:14pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/3 "2022-04-06T14:14:14Z")

</div>

Thank you, thank you!👍

Is there a way to retain whatever numerical value after the last **slash** ( **/** ) of the URLs? So that only the @usernameABC is replaced by @UPLOADER\_ID.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [April 6, 2022, 2:30pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/4 "2022-04-06T14:30:10Z")

</div>

I am still not sure what the source string looks like, which part is a variable one and how the target string should look like.  
If it is simply to replace the string `@usernameABC` with `%UPLOADER_ID%` the try  
`$replace(%fieldname%,@usernameABC,%uploader_id%)`  
I don't know in which field you put the URL that is why I set %fieldname% as dummy name.

---

<div class="post-metadata">

**Author:** ![Wakaku](https://community.mp3tag.de/user_avatar/community.mp3tag.de/wakaku/32/6418_2.png) [@Wakaku](https://community.mp3tag.de/u/Wakaku)\
**Post date:** [April 6, 2022, 2:46pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/5 "2022-04-06T14:46:39Z")

</div>

Below are real examples from ABC News and E! News respectively:

- [https://www.tiktok.com/@abcnews/video/7083277228259151146](https://www.tiktok.com/@abcnews/video/7083277228259151146)
- [https://www.tiktok.com/@enews/video/7083208028102626606](https://www.tiktok.com/@enews/video/7083208028102626606)

The real username can be found in the HTML source, in **AuthorID** , which are saved in MKV (or MKA) as **UPLOADER\_ID** , which are respectively:

- 6913995869449864197
- 242840465589526528

Therefore, I only want to replace,

- **@abcnews** and
- **@enews**

with their respective UPLOADER\_ID values which are inside the MKV. So I would like them to become:

- @6913995869449864197 and
- @242840465589526528 respectively.

I would like this because the owners of any TikTok accounts can change their friendly nicknames (eg. @abcnews, @enews) anytime, so the URL will become dead if they did so.

Therefore would finally become as:

- [https://www.tiktok.com/@6913995869449864197/video/7083277228259151146](https://www.tiktok.com/@6913995869449864197/video/7083277228259151146)
- [https://www.tiktok.com/@242840465589526528/video/7083208028102626606](https://www.tiktok.com/@242840465589526528/video/7083208028102626606)

From your original answer, it works but the trailing numerical values after the last slash were not retained.

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [April 6, 2022, 2:48pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/6 "2022-04-06T14:48:42Z")

</div>

So have you tried the bit that simply replaces?

> [@ohrenkino](#):
>
> `$replace(%fieldname%,@usernameABC,%uploader_id%)`

---

<div class="post-metadata">

**Author:** ![Wakaku](https://community.mp3tag.de/user_avatar/community.mp3tag.de/wakaku/32/6418_2.png) [@Wakaku](https://community.mp3tag.de/u/Wakaku)\
**Post date:** [April 6, 2022, 3:04pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/7 "2022-04-06T15:04:05Z")

</div>

> [@ohrenkino](#):
>
> $replace(%fieldname%,@usernameABC,%uploader\_id%)

The URL sadly got wholly deleted.

Here's a screenshot of MediaInfo that I would like to replace:

 ![sample](https://community.mp3tag.de/uploads/default/original/2X/6/6d9db8876e8cb9604e28e215d61e9cb324733d1e.png)

---

<div class="post-metadata">

**Author:** ![ohrenkino](https://community.mp3tag.de/user_avatar/community.mp3tag.de/ohrenkino/32/4843_2.png) [@ohrenkino](https://community.mp3tag.de/u/ohrenkino)\
**Post date:** [April 6, 2022, 3:29pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/8 "2022-04-06T15:29:54Z")

</div>

> [@Wakaku](#):
>
> The URL sadly got wholly deleted.

Then you would have to show me, what you did.

Or no, let's try this:  
Action of the type "Format value" for URL  
`$regexp(%url%,'https://www.tiktok.com/@.*/video/(.*)','https://www.tiktok.com/'%uploader_id%'/video/$1')`

---

<div class="post-metadata">

**Author:** ![Wakaku](https://community.mp3tag.de/user_avatar/community.mp3tag.de/wakaku/32/6418_2.png) [@Wakaku](https://community.mp3tag.de/u/Wakaku)\
**Post date:** [April 6, 2022, 3:48pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/9 "2022-04-06T15:48:03Z")

</div>

Yehey!😀 I only needed to add the **@** sign. Hence it became:

`$regexp(%url%,'https://www.tiktok.com/@.*/video/(.*)','https://www.tiktok.com/'@%uploader_id%'/video/$1')`

I tested the resulting URL, copy-pasted it into the browser's address bar, and it redirected correctly to the friendly nickname URL counterpart (instead of 404). Now, no more "not found" accounts when the owners changed their friendly nicknames.

Thank you, thank you!👍

---

<div class="post-metadata">

**Author:** ![system](https://community.mp3tag.de/uploads/default/original/2X/c/ce7035d426cb755a7916793326d23b465222a407.png) [@system](https://community.mp3tag.de/u/system)\
**Post date:** [May 6, 2022, 3:48pm UTC](https://community.mp3tag.de/t/tiktok-mkv-replace-part-of-url-using-value-from-a-field/55958/10 "2022-05-06T15:48:19Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
