# Get the name of the sample

**URL:** <https://in-thread.sonic-pi.net/t/get-the-name-of-the-sample/1984>\
**Category:** Support, Help & Resources\
**Created:** [February 8, 2019, 12:56pm UTC](https://in-thread.sonic-pi.net/t/get-the-name-of-the-sample/1984 "2019-02-08T12:56:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [February 8, 2019, 12:56pm UTC](https://in-thread.sonic-pi.net/t/get-the-name-of-the-sample/1984/1 "2019-02-08T12:56:56Z")

</div>

Hi,

A little question how to get the name of sample as in the screenshot i want to get “wren”.

```ruby
chemin_echantillons ="D:/audio/samples/birds"
sample chemin_echantillons

```

![image](https://europe1.discourse-cdn.com/flex017/uploads/sonic_pi/original/1X/a7ad0c79002941a281a0f9018dab2380f2733fda.png)

Thanks

---

<div class="post-metadata">

**Author:** ![nlb](https://dub1.discourse-cdn.com/flex017/user_avatar/in-thread.sonic-pi.net/nlb/32/997_2.png) [@nlb](https://in-thread.sonic-pi.net/u/nlb)\
**Post date:** [March 19, 2019, 7:05pm UTC](https://in-thread.sonic-pi.net/t/get-the-name-of-the-sample/1984/2 "2019-03-19T19:05:14Z")

</div>

Hi there,

Well i suggest this code to achieve my first goal.

```ruby
yourSamplesPath ="D:/audio/mesSamples/Jazz-02"

# ros = ring_of_samples
# filter samples only with loop into the name
ros = sample_paths yourSamplesPath, ""

## function to get only the name of the fileName to populate a friendly list by example
define :getName do |fullPath|
  fileNameWithExtension = fullPath.split("/")[-1] # to get the file name with the extension
  return fileName = fileNameWithExtension.split(".")[0] # to get the name without the extension
end

puts "---------------------------------"

puts "Number of samples : " + ros.length.to_s
puts "--------- Name of samples ------ "
k=0
while k<ros.length
  puts getName((ros)[k])
  # by example to be sent by osc_send to a list
  # to prepare the playing
  load_sample (ros)[k]
  k = k+1
end

puts "--- Let's play all the samples --------"

```

May it helps.  
Cheers
