String substitution on find results inside exec/xargs

What I'm trying to do is perform a copy, well a ditto actually, on the results of a find command, but some inline string substitution needs to happen.

So if I run this code

find ./ -name "*.tif"

I get back these results.

.//1234567.tif
.//abcdefg.tif

Now the action from exec or xargs I want would be these two things....

ditto .//1234567.tif /some/path/1/2/3/
ditto .//abcdefg.tif /some/path/a/b/c/

So as you can see it's taking the first three characters from each found result and using those to construct a path.

Any ideas I'm sure this can be done easier in a actual script, but i need to keep this as an actual "one line" command.

Any ideas?

find . -name '*.tif' |
sed -e 's%\(.//*\)\(.\)\(.\)\(.\)\(.*\)%ditto \1\2\3\4\5 /some/path/\2/\3/\4/%'
| sh

It's a thin line between a one-liner and an "actual script".

Thanks era, works great! Time to spend some time with the sed docs though... I knew it could do it, but admittedly I'm not very familiar with it :frowning: