Hi,
Try:
from1 <- list.files() ##folder where files are stored
from1
#[1] "p126r62_5t19880613_nn1.tif.gz" "p126r62_5t19880613_nn2.tif.gz"
#[3] "p200r65_5t19880613_nn1.tif.gz"
to1 <-
gsub("^p(\\d+)r(\\d+)\\_.{2}(\\d{8})\\_nn(.*)","LT5\\10\\2\\3_B\\4",from1)
file.rename(from1,to1)
#[1] TRUE T
You can do that like below:
startingDir<-"/myDirectory"
filez<-list.files(startingDir)
sapply(filez,FUN=function(eachPath){
file.rename(from=eachPath,to=sub(pattern="xxx",replacement="newTextString",eachPath))
})
On Mon, Feb 3, 2014 at 10:48 AM, arun wrote:
> Hi,
> Check ?file.rename(
Of course you can use file.rename() to do this.
Can you explain more the changing pattern in you case?
Best,
Qiang
On Mon, Feb 3, 2014 at 10:48 AM, arun wrote:
> Hi,
> Check ?file.rename()
> http://stackoverflow.com/questions/10758965/how-do-i-rename-files-using-r
>
>
> A.K.
>
>
> I have lis
Hi,
Check ?file.rename()
http://stackoverflow.com/questions/10758965/how-do-i-rename-files-using-r
A.K.
I have list of files in folder
e.g p126r62_5t19880613_nn1.tif.gz
p126r62_5t19880613_nn2.tif.gz
p200r65_5t19880613_nn1.tif.gz
and I would like to change file name to
LT51
use function system in R
for (x in 1:100){
system (paste("rename file0.",x,"_data.RData file",x,"_data.Rdata",sep=""))
}
-
Yasir Kaheil
--
View this message in context:
http://r.789695.n4.nabble.com/change-file-name-from-file0-1-data-RData-to-file1-data-Rdata-tp4637135p4637136.html
Sent from
Hello,
Follow this example.
# First see the regular expression
# at work without changing any disk file
x <- c("file0.1_data.RData", "file0.2_data.RData")
sub("^file0\\.", "file", x)
# Now change them
from.files <- list.files(pattern = "^file0\\.._data.Rdata$")
to.files <- sub("^file0\\.", "fi
Dear All,
I want to change file names.
I have file0.1_data.RData (I have several files whose names are
file0.x_data.Rdata)
I want to rename it to file1_data.RData
How can I do it?
Thank you for saving my time!
[[alternative HTML version deleted]]
__
7 matches
Mail list logo