I have a folder that contains 2000 photos. I have a list of photo file names, about 350 that i like to move from one folder to another rather then selecting them individually or going through line by line and selecting. Is there a easier way i can do it.

I can have the 350 file names in .txt if needed.

Copy selective 350 photo files from Directory A (2000 photofiles) to Directory B.

Thank you in advance.

2 Answers 2


Assuming no space characters etc in the filenames you can use Terminal to run

cd "/path/to/A"
cp -- $(< "/path/to/list_of_files") "/path/to/B/"

If there are space characters in the filenames, or if the command above fails because there are too many files, use

cd "/path/to/A"
while IFS= read -r f; do
  cp -- "$f" "/path/to/B/"
done < "/path/to/list_of_files"

PS: If you want to move the files, use mv instead of cp.


Make sure each file name is on its own line in the text file.

Then in Terminal, do this:

cd /path/to/photo/files
cat list_of_files.txt | while read FILE; do
  mv "$FILE" /path/where/you/want/them
  • 3
    Needless use of cat ... | as < files.txt can be place either in front of while or after done to read the files.txt. Also, the -r option should be used with the read command, and the destination path in the mv command should be shown quoted as a proper example in case the actual path has spaces (as well as the cd command). Jun 25, 2021 at 4:14
  • All the points @user3439894 made are valid. I do use this syntax a lot, with never an issue. But then, I NEVER put spaces in file names or directory names. I added the quote marks in case any of OP's file names had spaces, and I should have done it on the paths for the same reason.
    – WGroleau
    Jun 25, 2021 at 5:11
  • Spaces in file and folder names are incredibly common on macOS. Even system files contain them. It's rarely safe to assume their absence. It's a valid character in paths. Jun 25, 2021 at 18:11
  • I said I never create them, because after thirty-plus years in software, I am well aware that there still exist apps made by coders who fail to consider that a file name might contain other than alphanumeric. Nothing I can do about Apple pretending those coders don’t exist. Fortunately, system files rarely need me to mess with them.
    – WGroleau
    Jun 25, 2021 at 18:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .