Renaming multiple csv files

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

What operating system are you using? Windows or Linux?

@StevenSiew
I’m using a Windows system

A suggestion based on this solution:

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
2 Likes

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

1 Like

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

1 Like