This is a little helper named ncopy. It copies files from one place to another.
Syntax:
ncopy <files(s)> <target>
<files(s)> is just a filename (wildcards possible) and <target> is an expression for the target of the copy operation. So far there is nothing new. Here comes the interesting part:
In the target expression you can use the following to refer to parts of the source path and name:
*0 first directory after root
*1 second directory after root
...
*-1 first directory above sourcefile
*-2 second directory above sourcefile
...
*n name of the sourcefile
*s0 first suffix of the sourcefile
*s1 second suffix oft the sourcefile
So given the files a.txt and b.txt in c:\temp\foo\bar" and calling the script:
C:\temp\foo\bar>ncopy.pl *.txt .\*1\*n\*-1\t.*s0
mkpath C:\temp\foo\bar\foo\a\bar
a.txt -> C:\temp\foo\bar\foo\a\bar\t.txt
mkpath C:\temp\foo\bar\foo\b\bar
b.txt -> C:\temp\foo\bar\foo\b\bar\t.txt
As you can see you can easily transform file names while copying.
It's only tested under Windows, but
should be cross platform.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.