Hi John, After a bit of thinking: # fill in the appropriate path and pattern filenames<-list.files(path=???,pattern=???) for(filename in filenames) { filefirst<-sapply(strsplit(filename,"[.]"),"[",1) # delete all non-digits fileno<-gsub("[^[:digit:]]","",filefirst) file.rename(filename,paste("01Gen",fileno,".mp3",sep="")) } Jim