In Ubuntu all the files under the folder be copied to one folder?

The essence of what, exactly. There is a folder, it has a lot of subfolders and files. You need all the files to assemble one level to another folder. Assuming that if you got files with the same names, then look at the file size. If it is more replace if less skip.

Found this command:
find ./images -type f -exec sh-c "mv {} ./images2/" \;

But it does not take into account the size of the files with the same name. In console, Ubuntu is not strong. Help, please.
July 9th 19 at 10:57
1 answer
July 9th 19 at 10:59
write a script copying, such
FILE=$1
DEST=$2
BASENAME=`basename $FILE`
if test-f $DEST/$BASENAME
then
 SIZE_1 =$(stat -c%s "$FILE");
 SIZE_2 =$(stat -c%s "$DEST/$BASENAME");
 [[ SIZE_1-SIZE_2 gt ]] && cp $FILE $DEST/
else
 cp $FILE $DEST/
fi

call it say cp_action, throw it to ~
folder where to copy, let it be ~/src
the destination folder ~/dest
chmod +x ~/cp_action
find ~/src-type f -exec ~/cp_action {} ~/dest \;


Like this. If sales where a mistake, approximate the essence I think is clear.

Find more questions by tags Ubuntu