Re: [R] rename files in R

2022-09-19 Thread Rui Barradas
file names in some folder, and save to a new folder. Tim -Original Message- From: R-help On Behalf Of Kai Yang via R-help Sent: Friday, September 16, 2022 1:52 PM To: R-help Mailing List ; Rui Barradas Subject: Re: [R] rename files in R [External Email]   Hello,Here is the ex

Re: [R] rename files in R

2022-09-19 Thread Kai Yang via R-help
qual to that. > > Do a for loop using current file names in some folder, and save to a new > folder. > > Tim > > -Original Message- > From: R-help On Behalf Of Kai Yang via R-help > Sent: Friday, September 16, 2022 1:52 PM > To: R-help Mailing List ; Rui B

Re: [R] rename files in R

2022-09-19 Thread Bert Gunter
are in the first row, selecting the first element from > colnames() and setting the file name equal to that. > > > > Do a for loop using current file names in some folder, and save to a new > folder. > > > > Tim > > > > -Original Message- > > Fr

Re: [R] rename files in R

2022-09-19 Thread Kai Yang via R-help
-Original Message- > From: R-help On Behalf Of Kai Yang via R-help > Sent: Friday, September 16, 2022 1:52 PM > To: R-help Mailing List ; Rui Barradas > > Subject: Re: [R] rename files in R > > [External Email] > >  Hello,Here is the example: >    file name   

Re: [R] rename files in R

2022-09-16 Thread Rui Barradas
s Subject: Re: [R] rename files in R [External Email] Hello,Here is the example: file namefirst row file1.txt abc.txt file2.txt bed.txt file3.txt gogo.txt . . file1243.txtlast.txt I want to use loop because I need to read the first row information for first file, and

Re: [R] rename files in R

2022-09-16 Thread Kai Yang via R-help
Thank you. I'll try this. --- Kai On Friday, September 16, 2022 at 11:01:33 AM PDT, Rui Barradas wrote: Hello, Something like the following might work. filenames <- list.files(pattern = "^file\\d+\\.txt$") destnames <- sapply(filenames, scan, what = character(), sep = "\n", n = 1L,

[R] rename files in R

2022-09-16 Thread Kai Yang via R-help
Hello,I have a lot of files with not meaningful name, such as:  file1.txt, file2.txt .. I need to rename them using the information from the first row of the files. Now I can get the information from the first row of each file. Now, I need know how to rename them in R (using loop?). Thank yo