I'm a command line novice trying to figure out the appropriate command to execute the following within the Terminal in Mac OS X.
Assuming I've placed all files in the same directory, I want to isolate and move a selected set of directory files listed in a text file to a new directory, how do I:
read the selected list of filenames listed in a .txt file
find all matches by filename
isolate and move all file matches to a new directory
I've found this command to find (either or both) a filestring.filetype in a current directory and move all matches to a new directory:
find . -type f -iname "filestring.filetype" -print0 | xargs -0 -J % mv % ~/NewDirectory/
And I've found this
tar command however it creates an archive copy of each filename listed in
tar -cf - -T filename.txt | (cd /path/to/new/dir && tar -xvf -)
Any help is much appreciated!
The following solution was provided by a trusted source:
cat "filename.txt" | xargs -I % mv % ~/NewDirectory/