if you want to select column with specific name then just do
A=mtcars[,which(conames(mtcars)==cols[1])]
#and then
colnames(mtcars)[A]=cols[1]
you can run it in loop as well reverse way to add dynamic name eg if A is data frame and xyz is column to be named as x then I do like this
A$tmp=xyz
colnames(A)[colnames(A)=="tmp"]=x
again this can also be added in loop