# How to appned some string with file name

**URL:** <https://www.ruby-forum.com/t/how-to-appned-some-string-with-file-name/160528>\
**Category:** Rails\
**Created:** [February 17, 2009, 1:42pm UTC](https://www.ruby-forum.com/t/how-to-appned-some-string-with-file-name/160528 "2009-02-17T13:42:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 17, 2009, 1:42pm UTC](https://www.ruby-forum.com/t/how-to-appned-some-string-with-file-name/160528/1 "2009-02-17T13:42:35Z")

</div>

Dear all.  
using this below code i get file name of blob  
image = params[:image][:blob]  
puts image.methods  
image\_name = image.original\_filename  
it gives me  
=\> rose.jpg  
actually i want to append some string with it.how can i do it.pls help.  
example =\> rose\_big.jpg

Thanks

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 17, 2009, 2:22pm UTC](https://www.ruby-forum.com/t/how-to-appned-some-string-with-file-name/160528/2 "2009-02-17T14:22:26Z")

</div>

> > string = “rose.jpg”  
> > =\> “rose.jpg”
> 
> > modified = string[0…-5] + “\_big” + string[-4…-1]  
> > =\> “rose\_big.jpg”

you might wannt to check for the “.” in that string and cut it there.  
check out some ruby basics for string manipulation.

---

<div class="post-metadata">

**Author:** ![newb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/2acd7d/32.png) [@newb](https://www.ruby-forum.com/u/newb)\
**Post date:** [February 17, 2009, 2:53pm UTC](https://www.ruby-forum.com/t/how-to-appned-some-string-with-file-name/160528/3 "2009-02-17T14:53:05Z")

</div>

On Tue, Feb 17, 2009 at 4:42 AM, Newb N.  
\<removed\_email\_address@domain.invalid

> wrote:

> 

Hi, here’s another option using the File class:

filename = File.basename( filename, “.jpg” ) + "\_what\_ever\_you\_want

- File.basename( filename )

Good luck,

-Conrad
