Moving files and leaving links in bash
Instead of temporarily changing directories, you can call realpath to get the absolute path to a directory. There is also readlink which does similar job.



To generate the files array:

files=("$@"); unset "files[-1]"




The rest looks okay to me. However, keep your usage of ; consistent. If you are using it, put them in each statement; otherwise skip it altogether.