Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I'll be your Good Samaritan. First, let's cleanup your post.

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:
<p><i>Dear Monks</i></p>
For each paragraph, use tags like this:
<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>
For your list of files, I wrapped the paths with code tags.
<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>
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:

glob
rename
File::Copy
File::GlobMapper

Also, read and reread Writeup Formatting Tips

Now it's up to you. Good luck and keep trying!


In reply to Re: copy and rename depending on location by Khen1950fx
in thread copy and rename depending on location by oolmos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2024-04-19 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found