Very weird and specific question I know but would save me a big headache.
Is it possible to merge directories while removing a specific sub in each sub but keeping all files? Example
I have
/first/1/files/1.jpg, 2.jpg, 3.jpg
/first/2/files/1.jpg, 2.jpg, 3.jpg
I also have
/second/1/3.jpg, 4.jpg, 5.jpg
/second/2/3.jpg, 4.jpg, 5.jpg
I want to merge /first
into /second
while also removing the inbetween /files/
directory in /first
but keeping all the jpgs. On top of that, I don't want 3.jpg to be overwritten in /second/
If timestamps don't matter then you could do something like:
though that's not exactly what I'd call a good solution.
You could also do this manually testing for existing files while looping and copying like this:
I feel like there is probably a clever way to do this with rsync or cpio but I don't know what that is.