Using rsync:
while IFS=, read -r src dest; do
[ ! -d "$src" ] && echo "skipping missing directory \"$src\"" >&2 && continue
mkdir -p "$dest" && rsync -av --exclude='*/' --remove-source-files --ignore-existing "$src/" "$dest"
done < file.txt
This script reads file.txt line by line and assigns source and target directory to variables src and dest. The line is split on the comma defined in the IFS (internal field separator) variable.
If src is not a directory, the while-loop continues with the next line, otherwise the destination directory and its parent directories are created if it doesn't exist.
In the rsync call the following options are used (see man rsync):
-a archive mode (shorthand for options -rlptgoD)
-v verbose mode
--exclude='*/' exclude directories, only non-directories are transferred
--remove-source-files remove files from the sending side when transfer is complete (like mv)
--ignore-existing don't transfer files that already exist on the destination side
You could save the script as a shell script mv_rsync.sh:
#!/bin/sh
[ $# -ne 1 ] && echo "invalid file argument" >&2 && exit 1
while IFS=, read -r src dest; do
[ ! -d "$src" ] && echo "skipping missing directory \"$src\"" >&2 && continue
mkdir -p "$dest" && rsync -av --exclude='*/' --remove-source-files --ignore-existing "$src/" "$dest"
done < "$1"
Make it executable with
chmod +x ./mv_rsync.sh
and run it as
./mv_rsync.sh file.txt