On Thu, Apr 12 2012, Taylor Carpenter <taylor@codecafe.com> wrote: > On Thu, Apr 12, 2012 at 02:07, Tomi Ollila <tomi.ollila@iki.fi> wrote: > >> Btw: what if there are same filenames in different directories that >> match. With basename there will be collision. > > FYI, the current xargs version does not handle collisions either. True -- so that is not strictly a requirement ;) >> Alternatives: >> >> * instead of basename convert '/':s to '_':s >> * take md5 or sha1 sum of the filename >> * take md5 or sha1 sum of dirname of the filename and concatenate... > > How about pre-pending some unique text to the colliding file? Anything goes -- the target filename could also be generated ... like this: my $counter = 0; foreach(...) { chomp; my $target = sprintf("$maildir/cur/%08d", $counter++); symlink($_, $target); } i.e. target filename is just counter value. > Regards, > > Taylor Tomi