Great, but he will still want the slashes converted to underscores, will he not? I hope he doesn&#39;t have any underscores already in any directory or file names, else it will be non-reversible (and a little confusing).<div>
<br></div><div>Kevin<br><br><div class="gmail_quote">On Wed, Jul 7, 2010 at 2:09 PM, Adam Thompson <span dir="ltr">&lt;<a href="mailto:athompso@athompso.net">athompso@athompso.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
I&#39;ve had to do this before... there are some tools that&#39;ll do it for you, essentially you want the UNIX version of MS-DOS&#39;s &quot;UPDATE&quot; command.<br>
I would look at &quot;rsync&quot;, used in local mode, use something like<br>
<br>
        $ rsync -a --existing SRCDIR DSTDIR<br>
<br>
It is of course possible to do this in a shell script, but it&#39;s tricky to handle the recursion correctly unless you use an iterative find/grep series, which gets very expensive in terms of CPU time.<br>
<br>
The best non-recursive technique I can think of would be something like:<br>
        #!/bin/sh<br>
        SRC=&quot;$1&quot;<br>
        DST=&quot;$2&quot;<br>
        T1=$(mktemp)<br>
        T2=$(mktemp)<br>
        find &quot;${SRC}&quot; -type f -print | sed -e &quot;s/^${SRC}//&quot; | sort &gt; &quot;${T1}&quot;<br>
        find &quot;${DST}&quot; -type f -print | sed -e &quot;s/^${DST}//&quot; | sort &gt; &quot;${T1}&quot;<br>
        comm -12 &quot;$T1&quot; &quot;$T2&quot; | while read F ; do<br>
                cp &quot;${SRCDIR}${F}&quot; &quot;${DSTDIR}${F}&quot;<br>
        done<br>
<font color="#888888"><br>
-Adam<br>
</font><div><div></div><div class="h5"><br>
&gt; -----Original Message-----<br>
&gt; From: <a href="mailto:roundtable-bounces@muug.mb.ca">roundtable-bounces@muug.mb.ca</a> [mailto:<a href="mailto:roundtable-">roundtable-</a><br>
&gt; <a href="mailto:bounces@muug.mb.ca">bounces@muug.mb.ca</a>] On Behalf Of VE4ER / Andy<br>
&gt; Sent: Wednesday, July 07, 2010 12:10 PM<br>
&gt; To: MUUG Roundtable<br>
&gt; Subject: [RndTbl] script for file copy<br>
&gt;<br>
&gt; Can anybody suggest a script to copy files from one directory structure to<br>
&gt; another changing the filename in the process to include the original<br>
&gt; folder names, but only if an actual file with extension exists in the<br>
&gt; bottom child folder :<br>
&gt;<br>
&gt; Go from :<br>
&gt;<br>
&gt; Master Folder  ------&gt; Sub Folder1 -----&gt; Sub Sub Folder1 ---&gt;<br>
&gt; filename.example<br>
&gt;                          ------&gt; Sub Folder2 -----&gt; Sub Sub Folder1 ---&gt;<br>
&gt; filename.example<br>
&gt;                          ------&gt; Sub Folder2 -----&gt; Sub Sub Folder2 ---&gt;<br>
&gt; filename.example<br>
&gt;<br>
&gt;<br>
&gt; To:<br>
&gt;<br>
&gt;        /Var/MainFolder/Master_Sub1_SubSub1_filename.example<br>
&gt;         /Var/MainFolder/Master_Sub2_SubSub1_filename.example<br>
&gt;         /Var/MainFolder/Master_Sub2_SubSub2_filename.example   ....etc<br>
&gt;<br>
&gt;<br>
&gt; Thanks<br>
&gt; Andy<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Roundtable mailing list<br>
&gt; <a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
&gt; <a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
<br>
<br>
<br>
_______________________________________________<br>
Roundtable mailing list<br>
<a href="mailto:Roundtable@muug.mb.ca">Roundtable@muug.mb.ca</a><br>
<a href="http://www.muug.mb.ca/mailman/listinfo/roundtable" target="_blank">http://www.muug.mb.ca/mailman/listinfo/roundtable</a><br>
</div></div></blockquote></div><br></div>