The other problem you had was that you also had extra quotes on the mv line. When you are using echo to print a command that will be copied to a shell you need quote everything twice, once for this shell, and once for the second. your echo mv worked fine as long as the filename did not begin with a dash or contain a single quote. The mv only needed quoted once.
Here is how I would rewrite your snippet.
#!/bin/shbash cd ~/Data date="$(date -n +%Y-%m-%d)" for filename in *; do echo "${filename}" new_filename="$date$filename" filename_e="$(echo "$filename"|sed -e 's!\('\''\)!\\\1!')" new_filename_e="$(echo "$new_filename"|sed -e 's!\('\''\)!\\\1!')" echo mv -- \'"${filename_e}"\' \'"${new_filename_e}"\' mv -- "${filename}" "${new_filename}" done; This version will correctly rename any file with any character in the name. the only limitation is that the echoed command may produce commands that do not work in files that have a newline in the name.