in reply to copy and rename depending on location
Dear Monks:
I'm running into a fairly simple problem, but I have not been able to solve it. I have decided to look for some help. I'm not very good at scripting, and I was hoping that I would find a Good Samaritan on this website.
I have files in the following format:
/test1/da/0/1/nnn.dat /test1/da/0/2/nnn.dat /test1/da/0/3/nnn.dat /test1/da/y/n/nnn.dat /test1/da/y+1/n+1/nnn.dat /test1/da/y+1/n+2/nnn.dat /test1/da/y+n/n+n/nnn.dat
I want to copy all nnn.dat files that are located in every subfolder into a /newfolder/nnn.dat in such a way that each nnn.dat gets renamed according to its location.
For example:/newfolder/0_1_nnn.dat /newfolder/0_2_nnn.dat /newfolder/0_3_nnn.dat /newfolder/y_n_nnn.dat
I don't know where to start. What would be a good starting point? Thank you for your help.
===============================================================How did you do that?
For "Dear Monks:", I wrapped the expression in paragraph and italic tags:For each paragraph, use tags like this:<p><i>Dear Monks</i></p>
For your list of files, I wrapped the paths with code tags.<p>I'm running into a fairly simple problem but I have not been able t +o solve it. I have decided to look for some help. I'm not very good a +t scripting , and I was hoping I would find a Good Samaritan on this +website.</p>
Looking good... Now what? You'll need to follow Grandfather's advice and try to put a script together. You can start by studying the documentation for:<code> /test1/da/0/1/nnn.dat /test1/da/0/2/nnn.dat /test1/da/0/3/nnn.dat /test1/da/y/n/nnn.dat /test1/da/y+1/n+1/nnn.dat /test1/da/y+1/n+2/nnn.dat /test1/da/y+n/n+n/nnn.dat </code>
glob
rename
File::Copy
File::GlobMapper
Also, read and reread Writeup Formatting Tips
Now it's up to you. Good luck and keep trying!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: copy and rename depending on location
by oolmos (Initiate) on Oct 08, 2011 at 18:24 UTC |