# Renaming uploaded files

**URL:** https://meta.discourse.org/t/renaming-uploaded-files/172854
**Category:** Support
**Created:** [December 10, 2020, 12:59pm UTC](https://meta.discourse.org/t/renaming-uploaded-files/172854 "2020-12-10T12:59:06Z")
**Posts on this page:** 1
**Showing post:** 6

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 10, 2020, 4:23pm UTC](https://meta.discourse.org/t/renaming-uploaded-files/172854/6 "2020-12-10T16:23:40Z")

</div>

Wait. I’m not quite sure what you’re trying to do. Is it to change the name people see in the posts in which they’re uploaded? If that’s the case, then maybe you want to do something like

```plaintext
rake posts:remap["old-name.pdf","newname.pdf"]

```

As described in [Replace a string in all posts](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729). I think that for your purposes the original filename in the Upload model doesn’t really matter.

But you can change that with

```plaintext
u=Upload.find_by(original_filename: 'mypretty-w9.pdf')
u.original_filename='better-name.pdf'
u.save

```

I tried rebaking a post with that upload and nothing happened.

EDIT:

```plaintext
def rename_upload(old_name, new_name)
  u=Upload.find_by(original_filename: old_name)
  u.original_filename=new_name
  u.save
end

```

If you paste that, then you can

```
rename_upload('name.pdf','better-name.pdf')

```

It’ll fix it so that the downloads get the better filename.

In my former life as an academic I had **my** specific way of naming my PDFs that was different from anyone else’s; I’m pretty sure that my wife has her own. My guess is that no one will like your filenames even when you get them “right”. 😉

---

_[View the full topic](https://meta.discourse.org/t/renaming-uploaded-files/172854)._
