I want to move the files listed in files_to_mv.txt
to a new folder called dest_dir/
using Bash. The files to move (photos with a .jpg
extension) and the dest_dir/
are located in the same folder.
The files_to_mv.txt
file looks like this
photo_1.jpg
photo_2.jpg
photo_3.jpg
after cd
-ing to the folder that contains the photos and destination folder, I have tried the following
while read file; do mv "$file" /dest_dir; done < files_to_mv.txt
and
for file in $(cat files_to_mv.txt); do mv "$file" /dest_dir; done
both of which give the error
mv: cannot stat 'photo_1.jpg'$'\r': No such file or directory
mv: cannot stat 'photo_2.jpg'$'\r': No such file or directory
What am I doing wrong?