Answer the question
In order to leave comments, you need to log in
How to download files using links from a table?
Good people, please help with a bash script,
there is a table with a full name and a link to a photo, how to download a photo and rename it to a full name?
I need it urgently, but I can’t figure it out on Friday already)
Answer the question
In order to leave comments, you need to log in
#!/bin/bash
set -e
FOLDER="photos"
mkdir -p $FOLDER
function download () {
local url=$1
local name=$2
filename=$(basename "$url")
extension="${filename##*.}"
wget -O"${FOLDER}/${name}.${extension}" "${url}"
}
while read line
do
name=$(echo $line | awk -F ";" ' {print $1} ' | sed -e "s/\ /_/g")
url=$(echo $line | awk -F ";" ' {print $2} ')
download "${url}" "${name}"
done < $1
Ярков Алексей Николаевич;https://avatars2.githubusercontent.com/u/6022892?v=4&s=460
Иванов Иван Иванович;https://avatars2.githubusercontent.com/u/23380632?v=4&s=460
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question