<p>Craft CMS has a <a href="https://craftcms.com/docs/5.x/reference/cli.html#utils-ascii-filenames" rel="nofollow noreferrer">console command</a> <code>utils/ascii-filenames</code> which should do what you need: convert all non ASCII filenames to ASCII filenames which should work on any server.</p>
<p>Additionally there's a config parameter, which should do this right after upload. <code>-&gt;convertFilenamesToAscii(true)</code></p>
<p>See <a href="https://craftcms.com/docs/5.x/reference/config/general.html#convertfilenamestoascii" rel="nofollow noreferrer">https://craftcms.com/docs/5.x/reference/config/general.html#convertfilenamestoascii</a></p>

CC BY-SA 4.0
2024-10-16T09:12:48.627Z
Thanks Max, will give it a try
Malcolm Maclean
CC BY-SA 4.0
2024-10-16T10:14:53.347Z
Hi Max, I tried this out and it seemed to change some file names and not others no idea why. It found 10 files to change (when i can see there are a lot more than that).

I have put a couple of example file names below that were not changed incase this sheds any light and i need a different command?!

Image 3_ Tonbridge School.jpg
Image 2_ Cheltenham Ladies' College.jpg
Image 4_ Marlborough College.jpg
Malcolm Maclean
CC BY-SA 4.0
2024-10-16T15:15:31.510Z
Did you try to update the search indexes and rerun the command after?
Max Strebel
CC BY-SA 4.0
2024-10-18T08:32:39.600Z
I resaved all the assets using 'php craft resave/assets --update-search-index' and then ran 'php craft utils/ascii-filenames' but found no assets with non-ASCII filenames
Malcolm Maclean
CC BY-SA 4.0
2024-10-20T08:06:52.167Z
Hey, sorry I meant the asset indexes (`php craft index-assets/all`).
Max Strebel
CC BY-SA 4.0
2024-10-15T19:21:13.363Z
2024-10-15T19:21:13.363Z
Max Strebel
<p>On one of my clients sites I am getting an issue with spaces in asset names. For example</p>
<ul>
<li>This is the file uploaded: Plan of a Court.jpg</li>
<li>If i click to preview in a browser it changes the spaces to '%20' but works ok
Plan%20of%20a%20Court.jpg</li>
<li>If i click on the asset to goto the detail page it gives me a 403 error with this url /admin/assets/edit/9674-Plan%20of%20a%20Court</li>
<li>If i change the '%20' to '-' it works fine then e.g. /admin/assets/edit/9674-Plan-of-a-Court</li>
</ul>
<p>It seems like i need to do some kind of batch change to correct this for my client maybe? (They have a lot of assets)</p>

<assets>
Assets with spaces in name causing issue in admin
# Assets with spaces in name causing issue in admin

(Asked by: username_0 on 2024-10-15)

On one of my clients sites I am getting an issue with spaces in asset names. For example

* This is the file uploaded: Plan of a Court.jpg
* If i click to preview in a browser it changes the spaces to '%20' but works ok
  Plan%20of%20a%20Court.jpg
* If i click on the asset to goto the detail page it gives me a 403 error with this url /admin/assets/edit/9674-Plan%20of%20a%20Court
* If i change the '%20' to '-' it works fine then e.g. /admin/assets/edit/9674-Plan-of-a-Court

It seems like i need to do some kind of batch change to correct this for my client maybe? (They have a lot of assets)

**Tags:** assets


---

## 1 answers

### Answer by username_1 on 2024-10-15. Score: 2

Craft CMS has a [console command](https://craftcms.com/docs/5.x/reference/cli.html#utils-ascii-filenames) `utils/ascii-filenames` which should do what you need: convert all non ASCII filenames to ASCII filenames which should work on any server.

Additionally there's a config parameter, which should do this right after upload. `->convertFilenamesToAscii(true)`

See <https://craftcms.com/docs/5.x/reference/config/general.html#convertfilenamestoascii>

> **Comments:**
> **username_0**: Thanks Max, will give it a try  
> **username_0**: Hi Max, I tried this out and it seemed to change some file names and not others no idea why. It found 10 files to change (when i can see there are a lot more than that).  I have put a couple of example file names below that were not changed incase this sheds any light and i need a different command?!  Image 3_ Tonbridge School.jpg Image 2_ Cheltenham Ladies' College.jpg Image 4_ Marlborough College.jpg  
> **username_1**: Did you try to update the search indexes and rerun the command after?  
> **username_0**: I resaved all the assets using 'php craft resave/assets --update-search-index' and then ran 'php craft utils/ascii-filenames' but found no assets with non-ASCII filenames  
> **username_1**: Hey, sorry I meant the asset indexes (`php craft index-assets/all`).  

---

