# Renaming multiple csv files

**URL:** <https://discourse.julialang.org/t/renaming-multiple-csv-files/70005>\
**Category:** New to Julia\
**Tags:** filesystem\
**Created:** [October 18, 2021, 9:16pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005 "2021-10-18T21:16:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbah](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@mbah](https://discourse.julialang.org/u/mbah)\
**Post date:** [October 18, 2021, 9:16pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/1 "2021-10-18T21:16:07Z")

</div>

Hello,

I am currently working with csv files in my directory with the following naming format (20200702pal.csv) corresponding to a particular day of the year.

I would like to rename all the files by adding an underscore between the year, month and day and removing pal at the end as follows: **2020\_07\_02.csv**

Is there a Julia solution to iterate the new naming format over hundreds of files?

Thanks

---

<div class="post-metadata">

**Author:** ![StevenSiew](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevensiew/32/218393_2.png) [@StevenSiew](https://discourse.julialang.org/u/StevenSiew)\
**Post date:** [October 18, 2021, 9:26pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/2 "2021-10-18T21:26:31Z")

</div>

What operating system are you using? Windows or Linux?

---

<div class="post-metadata">

**Author:** ![mbah](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@mbah](https://discourse.julialang.org/u/mbah)\
**Post date:** [October 18, 2021, 9:27pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/3 "2021-10-18T21:27:55Z")

</div>

@StevenSiew  
I’m using a Windows system

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [October 18, 2021, 10:17pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/4 "2021-10-18T22:17:25Z")

</div>

A suggestion based on [this solution](https://discourse.julialang.org/t/rename-multiple-files-in-the-folder-with-julia/57976/2):

```julia
dir = raw"C:\Users\jrafa\CSVFILES"
cd(dir)
csvfiles = filter(endswith("pal.csv"), readdir())
for file in csvfiles
    mv(file, file[1:4]*"_"*file[5:6]*"_"*file[7:8]*".csv")
end

```

---

<div class="post-metadata">

**Author:** ![gustaphe](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gustaphe/32/18174_2.png) [@gustaphe](https://discourse.julialang.org/u/gustaphe)\
**Post date:** [October 18, 2021, 11:15pm UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/5 "2021-10-18T23:15:15Z")

</div>

Windows PowerToys has a batch rename tool. I’ve never used it, but I imagine it can do this.

---

<div class="post-metadata">

**Author:** ![mbah](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@mbah](https://discourse.julialang.org/u/mbah)\
**Post date:** [October 19, 2021, 7:09am UTC](https://discourse.julialang.org/t/renaming-multiple-csv-files/70005/6 "2021-10-19T07:09:15Z")

</div>

@rafael.guerra Thanks a lot! Your solution worked out
