Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

screen shot of the terminal

How to copy all .aze files that have different contents into folder3 ? The screen show what I don't want to do. What I want to get close is to have in folder 3, file1(1).aze and file1(2).aze (and other .aze)

I want the two version of file1.aze in folder 3.

I use

find -name "*.aze" -exec cp {} folder3/ \;

I tried adding --parents but it also keep file that have same contents and same name. (I only want one copy of each version.)

share|improve this question

migrated from Mar 17 '13 at 1:24

This question came from our site for professional and enthusiast programmers.

up vote 1 down vote accepted

It's not clear to me what your desired result is. Do you want both folder1/file1.aze and folder2/file1.aze to go directly into folder3?

  +-file1.aze        # <-- from folder1
  `-file1.aze        # <-- from folder2

That isn't possible without renaming at least one of the files. Something like this may work for renaming files with sequential numbers:


filename="$(basename "$1")"
basename="$(basename "$1" "$extension")"

[ "$(dirname "$1")" == "$dst" ] && exit 0

while [ -f "$dst/$filename" ]; do

cp "$1" "$dst/$filename"

Run it like this:

find -name "*.aze" -exec ./ {} \;

What do you want to achieve anyway? For keeping multiple versions of the same file, you'd better use a revision control system like Subversion, Mercurial or git.

share|improve this answer
Hi, that's exactly what I'd like to achieve. I know they have to be renamed like file1(1).aze and file1(2).aze. It's just that i've got a lot of .odt files in a really complex tree, it's a big mess and I just want to get every .odt without missing anything because of they got the same name. I'll only do this once. – user2178064 Mar 16 '13 at 22:25
Thanks a lot, everything worked, awesome bash script ! Only things it can't do is that it checks if file with same name aren't the same. But I'm pretty sure there's another command that can help me have only unique files. Good evening – user2178064 Mar 16 '13 at 23:07
@user2178064 Use diff to check if two files are different. – Ansgar Wiechers Mar 16 '13 at 23:21
Yep, I've found that command, but i've got hundred of files. Oh and any idea why in the final folder I found some files with name like that : "math 4(5)(1).odt" and "math(5).odt" and all the other math(1...5).odt. Implementing an if condition in the script look too hard. I'll do it manualy I think. – user2178064 Mar 16 '13 at 23:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.