Copy files from Folder A to Folder B based on Text File C with bash How do I copy files from Folder A to Folder B based on Text File C with bash?


folderA: source folder with image files only, e.g. image01.png, image02.png etc. There are no space in the image names, only dash or underscore
folderB: destination folder with nothing inside.
C.txt: is a UTF16 encoded raw text file, inside the text file stored the file names that I want to copy from folderA  and these file names are line by line

image01.png
image02.png
image04.png



Specific paths are


~/Documents/C.txt
~/Documents/folderA/
~/Documents/folderB/
Assuming your file C contains a list of file names to copy:

A="~/Documents/folderA"
B="~/Documents/folderB"
while IFS= read -r file; do
    cp "${A}/${file}" "${B}/"
done &lt; ~/Documents/c.txt


should do the trick.