I would like to create loop to execute some tasks for every line:
while read line
do
I need to copy files from every line i.e. /media/cache/281662-19.jpg to other location but with name given in PATH: so the result will be like this: title6.jpg
done < $FILE
Text file is just example and every line will be different apart from tag PATH: and FILE: which I added myself to make it easier.
Path after FILE: is path to existing file which has to stay in place as it is.
Path after PATH: shows name and new location of file from FILE:
I have a jpg files in /media/cache/. Each jpg coresponds to its movie file as it its cover so I need to create rule which will copy jpg from cache to i.e. /media/video where movie exists. That copied jpg has to be also renamed and name is given after PATH: in that text file.
This rule has to do its job for every line in this file.
Hope this makes it more clear.
edit:
More or less it works with clue you gave me. I just modified my text file a bit:
sed -i 's/avi FILE/jpg FILE/g' $FILE
sed -i 's/mkv FILE/jpg FILE/g' $FILE
while read P F; do cp ${F#*:} ${P#*:}; done < $FILE
but now I have to find a way to copy files when space is inside the title. Now copy command just cut ater first occurence of space.