Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
added 18 characters in body; edited tags
Source Link
zx8754
  • 56.7k
  • 12
  • 131
  • 229

There are some .fcs files in a data.000X format (where X = 1, 2, 3...) in a directory. 

I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
  

in other words:
I I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For

For example, from:
data.0001, data.0002, data.0003, data.0004, data.0005, data.0006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

data.0001, data.0002, data.0003, data.0004, data.0005, data.0006... 

to

textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ... 

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 

There are some .fcs files in a data.000X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
 in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.0001, data.0002, data.0003, data.0004, data.0005, data.0006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 

There are some .fcs files in a data.000X format (where X = 1, 2, 3...) in a directory. 

I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file. 

in other words: I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.

For example, from:

data.0001, data.0002, data.0003, data.0004, data.0005, data.0006... 

to

textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ... 

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 
added 7 characters in body
Source Link
abc
  • 177
  • 1
  • 4
  • 19

There are some .fcs files in a data.00X000X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.0010001, data.0020002, data.0030003, data.0040004, data.0050005, data.0060006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 

There are some .fcs files in a data.00X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.001, data.002, data.003, data.004, data.005, data.006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 

There are some .fcs files in a data.000X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.0001, data.0002, data.0003, data.0004, data.0005, data.0006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 
edited code chunk, deleted "tagline" (see faq)
Source Link
Roman Luštrik
  • 70.9k
  • 25
  • 160
  • 203

There are some .fcs files in a data.00X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.001, data.002, data.003, data.004, data.005, data.006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$")
b <- paste("data", 1:1180, ".fcs", sep = "")
file.rename(a, b)

Please help

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 

There are some .fcs files in a data.00X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.001, data.002, data.003, data.004, data.005, data.006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$")
b <- paste("data", 1:1180, ".fcs", sep = "")
file.rename(a, b)

Please help

There are some .fcs files in a data.00X format (where X = 1, 2, 3...) in a directory. I want to rename every n file to the following format: exp.fcs (where exp is a text from a vector) if the file to be renamed is an .fcs file.
in other words:
I want to rename files to exp.txt, where exp is a text and not a consecutive letter(s) i.e. F, cA, K, etc.
For example, from:
data.001, data.002, data.003, data.004, data.005, data.006...
to
textF_a.fcs, textF_b.fcs, textF_c.fcs, textVv_a.fcs, textVv_b.fcs, textVv_c.fcs ...

I tried to do it with file.rename(from, to) but failed as the arguments have different lengths (and I don't know what it means...):

a <- list.files(path = ".", pattern = "data.*$") b <- paste("data", 1:1180, ".fcs", sep = "") file.rename(a, b) 
Post Migrated Here from stats.stackexchange.com (revisions)
Source Link
stan
  • 177
  • 1
  • 4
  • 19
Loading