0

There are two folders named Folder1 and Folder2. Folder1 has files with name:For example S-080001-0-0.xml with its corresponding same files in Folder2 named S-080001-0-0.xml

The change in Folder2 is that,for same file in Folder1 which is S-080001-0-0.xml,Folder 2 contains multiple files with different value after hyphen,like -080001-0-0.xml,-080001-0-1.xml,-080001-0-2.xml,-080001-0-3.xml. My challenge is to move all the files of same name from these two folders.

1
  • Please explain. Do you want to add Folder1/S-080001-0-0.xml after, e.g., Folder2/S-080001-0-5.xml as Folder2/S-080001-0-6-xml? Combine them somehow?
    – vonbrand
    Commented Feb 26, 2013 at 10:19

1 Answer 1

0

If you want to compare based on filename then you can use below :

find folder1/ folder2/ -type f -printf %f"\n" | sort |  uniq -c | \
awk '( $1 >= 2 ) {print "mv -vf folder1/"$2,"other_dir/","&&","mv -vf folder2/"$2,"other_dir/"}'

it will just print command on terminal , it will not execute that , if you see output is proper then just append | sh at the last then it will execute that command

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .