# Help with Created an Action to remove trailing space from filename

**URL:** https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633
**Category:** Support
**Created:** [January 6, 2023, 10:10pm UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633 "2023-01-06T22:10:42Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cldcp00](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@cldcp00](https://community.mp3tag.de/u/cldcp00)
#### Post date: [January 6, 2023, 10:10pm UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/1 "2023-01-06T22:10:42Z")

</div>

I have lots of files that have a space before the file extension e.g " .mp3" example of file

"Smokey Robinson - Everybody Needs Love .mp3"

Result I would like

"Smokey Robinson - Everybody Needs Love.mp3"

Thanks for any help

---

<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 6, 2023, 10:19pm UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/2 "2023-01-06T22:19:46Z")

</div>

What do your tags look like?  
You could then rewrite the filename with Convrt\>Tag-Filename  
Format string: `$trim(%artist% - %title%)`

Also, a look at the FAQs could be helpful:

> [@Actions and batch-operations](https://community.mp3tag.de/t/actions-and-batch-operations/967/10):
>
> How to remove/trim leading and trailing spaces [Video tutorial for these actions](http://www.vimeo.com/7756545) Leading spaces: Action type: Replace with regular expressions Field: \_TAG Regular expression: ^\s+ Replace matches with: ^ matches the beginning of the string. Then \s+ searches for all whitespaces till a different char occurs. The whitespaces found will be replaced by nothing and, thus, deleted. Trailing spaces: Action type: Replace with regular expressions Field: \_TAG Regular expression: \s+$ Replace matc…

---

<div class="post-metadata">

### Author: ![cldcp00](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/c/838e76/32.png) [@cldcp00](https://community.mp3tag.de/u/cldcp00)
#### Post date: [January 6, 2023, 11:07pm UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/3 "2023-01-06T23:07:32Z")

</div>

That's the problem they currently have no tags, so I want to clean up the filename and then create the tags from the filename.

---

<div class="post-metadata">

### Author: ![LyricsLover](https://community.mp3tag.de/letter_avatar_proxy/v4/letter/l/c6cbf5/32.png) [@LyricsLover](https://community.mp3tag.de/u/LyricsLover)
#### Post date: [January 6, 2023, 11:22pm UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/4 "2023-01-06T23:22:05Z")

</div>

> [@cldcp00](#):
>
> so I want to clean up the filename and then create the tags from the filename.

You could try it the other way around:

Derive the tags from your filename like this:  
Use the two placeholders  
`%artist% - %title% `  
followed by a space (not visible above) in the Format string.

It should look like this and show content for **artist** and **title**  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/1/188653e38b806af8e198cf4f660281aab563ce8c.png)

This fills the artist and the title without trailing space for filenames like  
`Smokey Robinson - Everybody Needs Love .mp3`  
This will NOT WORK for filenames without trailing space, like  
`Smokey Robinson - Everybody Needs Love.mp3`

For this filenames without trailing space, do the same as above but without trailing space in the Format string:  
 ![image](https://community.mp3tag.de/uploads/default/original/2X/4/43bfcdb0f385e1b21eadb84c2ea8692d2cefe650.png)

As soon as you have filled the tags ARTIST and TITLE for all your tracks, you can start renaming your files as @ohrenkino wrote. The command `$trim()` is not really needed anymore, since you should not have leading or trailing spaces in your tags.

---

<div class="post-metadata">

### Author: ![poster](https://community.mp3tag.de/user_avatar/community.mp3tag.de/poster/32/4881_2.png) [@poster](https://community.mp3tag.de/u/poster)
#### Post date: [January 7, 2023, 7:03am UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/5 "2023-01-07T07:03:03Z")

</div>

It is mostly the best solution to build up a filename from the tags.  
But it is also possible to do it the other way round, especially because in this case you can avoid the step of filtering for files that have these spaces in the filename.

Use the converter Tag-\>Tag  
Field: \_FILENAME  
Format String: $trim(%\_filename%)

Then use the converter Filename-\>Tag.  
Format String: `%artist% - %title%`

---

<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: [February 6, 2023, 7:03am UTC](https://community.mp3tag.de/t/help-with-created-an-action-to-remove-trailing-space-from-filename/59633/6 "2023-02-06T07:03:09Z")

</div>

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