I have a folder "all_images/" with more than 1000 image files named as "Image1.tif", "Image2.tif" and so on..
I have a text file "extract_images_list.txt" which is a list of images that I want to extract from this folder.
Example:
Image23.tif
Image100.tif
Image248.tif
I want to move only those files mentioned in my text file to another folder "extract_images/"
I could only think of
rm (Image1|Image2|Image3|...|...|....|)
where I would provide the images that I don't want.
Is there a better way of doing this?
With the caveat that this solution can't possibly handle things like the Line Feed character being in a filename:
mkdir extract_images 2>/dev/null
while IFS= read -r file; do
mv "$file" extract_images
done < extract_images_list.txt
This goes through extract_images_list.txt line-by-line by reading them into the file
variable (the -r
argument is required to make it treat backslashes as literal backslashes, and IFS=
makes it not strip whitespace), then moves each line to the extract_images directory.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments