Recently the leader has given a task to deal with the line-piece server, unwanted pictures to remove it.
Idea: First the line to use the image from the database to export, the table has a picture path, and then the path to generate a txt
Finally, each picture path is read from the TXT file and processed accordingly.
The following is the script used, because the picture is more, about 17W, took 2 hours, put the script up for later reference
#!/bin/bash
Cat/usr/local/src/goodimg.txt | While read line #goodimg. txt is the txt text of the picture exported from the database
Do
Dst=/opt/central-images/upfiles/goods_img2
Echo ' pwd: ' $line
Src=/opt/central-images/upfiles/goods_img
new=$ ((dirname $line) | sed "s:${src}:${dst}:g")
Echo ' new= ' $new
Echo ' copy_to: ' $new
Mkdir-p $new
echo $line $new
CP $line $new
#break;
Done
Shell batch processing picture server