Sure, you can do this with a very small Bash script.
I'm assuming that you have the list chosen.txt
in your home directory, of which Pictures is a subdirectory. If this isn't the case, please adjust the paths accordingly.
First make the directory to move the files into. I'm assuming you've just opened a terminal and you're in your home directory. You can move the directory later.
mkdir ChosenOnes
Now check if you can find the correct files using your list like this:
while read -r line; do find Pictures -name "$line" -ls; done < chosen.txt
If the result looks correct, you can copy the files by adjusting the command:
while read -r line; do find Pictures -name "$line" -exec cp -vt ChosenOnes {} \; ; done < chosen.txt
We can make that look a bit better:
#!/bin/bash
# read our list and
while read -r line; do
# find the files in it and copy them to the new directory
find Pictures -name "$line" -exec cp -vt ChosenOnes {} \;
done < chosen.txt
Explanation
while read -r line; do things; done < input-file
A while
loop keeps on doing something as long as a condition holds. Here we are asking our list to be read line by line. Each line is going to be put into the variable line
so that we can run some command(s) on it. When we're done with our command(s) on that line, the next line will be read, until we run out of lines in our file.
find path -name "$line"
The find
command does a recursive search down from the given path (Pictures in our case). Here we use the -name
option to find files matching the names in the list.
-ls
The find
command has an option to list out the found files. This is useful for checking on what's been found before taking any action
-exec command {} \;
The -exec
option to find runs the given command on the files that have been found (represented by {}
)
cp -vt
The -v
option makes cp
tell us what it's doing. The -t
option specifies the destination (we give the destination directory immediately after it); otherwise the destination will be assumed to be the last argument.