I'm trying in php to move a folder but keep both files in the dest folder if exist duplicate. i tried todo that in recursion but its too complicated so many things can go wrong for example file premissions and duplicate files\folders.

im trying to work with system() command and i cant figure out how to move files but keep backup if duplicate without destroying the extension

$last_line = system('mv --backup=t websites/test/ websites/test2/', $retval);

gives the following if file exist in both dirs:

ajax.html~
ajax.html~1
ajax.html~2

what im looking for is:

ajax~.html
ajax~1.html
ajax~2.html

or any other like (1), (2) ... but without ruining the extension of the file. any ideas? please.

p.s must use the system() command.

Edit
Report