Apologies if this question has been asked in another way somewhere else; I have looked but couldn't find a specific answer.
Anyway, what I want to do is as follows:
I have a folder of files sequentially named with the year and month in their titles, i.e. Fetch_1961-01_Actual.txt, Fetch_1961-02_Actual.txt, ..., Fetch_2002-12_Actual.txt.
What I want to do is rename them so that they are named with a simple index of month by year, i.e. 01.1961.txt, 02.1961.txt, ..., 12.2002.txt.
Any help would be greatly appreciated.
Thanks in advance.
Gregg
PS. I have managed to get this sorted using the following code in R:
mypath <- "path/to/files"
a <- list.files(path = mypath)
mn <- 1:12
yr <- sort(rep(1961:2002, 12))
for (i in yr) {
b <- paste(rep(mn, 2002-1961), ".", yr, ".txt", sep = "")
}
file.rename(a,b)
Not very elegant, but it saved me a few hours.
Cheers