diff --git a/Dockerfile b/Dockerfile index 8039891..45a6385 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,12 +1,14 @@ -FROM golang:latest as BUILD +FROM alpine +COPY gather-media.sh /bin/gather-media +#FROM golang:latest as BUILD -WORKDIR /gather-media +#WORKDIR /gather-media -COPY go.mod ./ -# COPY go.sum ./ +#COPY go.mod ./ +## COPY go.sum ./ -RUN go mod download +#RUN go mod download -COPY *.go ./ +#COPY *.go ./ -RUN go build -o /bin/gather-media +#RUN go build -o /bin/gather-media diff --git a/gather-media.sh b/gather-media.sh new file mode 100755 index 0000000..ab4d79d --- /dev/null +++ b/gather-media.sh @@ -0,0 +1,13 @@ +#! /bin/sh + +echo "scanning $1 for attachments" +noteName=$(echo $1|awk -F'/' '{print $(NF-1)}') + +attachments=$(cat $1|egrep "\[\[(Resources\/attachments\/.*?)\]\]"|tr -d '![]'|awk -F'/' '{print $(NF)}') +echo "Found Attachments:" +echo $attachments + +for a in $attachments; do + # echo "find . -name $a -exec mv {} /tmp/blog/content/notes/$noteName/$a \;" + find . -name $a -exec mv {} /tmp/blog/content/notes/$noteName/$a \; +done diff --git a/main.go b/main.go index 7e22b15..729d043 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,6 @@ func scanReader(r io.Reader, path string, matchChan matches) { for _, match := range matches { dirs := strings.Split(path, "/") noteFilename := dirs[len(dirs)-2] - log.Println("noteFilename:", noteFilename) matchChan <- Attachment{Filename: match[1], Note: noteFilename} } }