jya-dev / supernote-tool

Unofficial python tool for Supernote
Apache License 2.0
237 stars 25 forks source link

Convert all files in a directory #19

Open FinbarArgus opened 1 year ago

FinbarArgus commented 1 year ago

I'm not sure if there is a way to do this already.

This works in a bash file but would be nice if it could be done without a bash script

#!/bin/bash
for filename in ./*.note; do
  supernote-tool convert -t pdf -a "$filename" "${filename/.note/.pdf}"
done

p.s. Super handy tool, thank you!

cwhittl commented 1 year ago

Doesn't fix your issue but here is a more dynamic version that will move them to another directory

#!/bin/bash
find ../Supernote -name "*.note" -print0 | while read -d $'\0' file
do
    newFile="${file/Supernote/Supernote_Converted}"
    newFile="${newFile%.*}.pdf"
    newDir="$(dirname "${newFile}")" 
    mkdir -p "${newDir}"
    supernote-tool convert -t pdf -a "$file" "$newFile"
done
cwhittl commented 1 year ago

@FinbarArgus I've made some changes and are running through cron every 5 minutes https://gist.github.com/cwhittl/2e384fedc4aef449a87365d5a80340a2

adityam commented 1 year ago

I created a docker image which converts all files in the supernote directory to pdf (using rake rather than make, simply because I understand rake better).

https://adityam.github.io/linux-blog/post/converting-supernote-files-to-pdf/

bones3i commented 1 year ago

Here is my version that is run as a .bat file on windows scheduler every night. It only converts files that have been edited in the last couple of days (or day). It creates a cloned file structure of \NOTE in \EXPORT but with converted pdf's. This only processes .note files not pdf.mark files. Just remove the ' at the beginning, before the > nul, and at the end

'@echo off

echo New Supernote files in the last day being converted then moved. Find this file To edit in j-AppData. set /A MINAGE=0, MAXAGE=1

set "MAXAGE=%MAXAGE:-=%" & set "MINAGE=%MINAGE:-=%" & set /A MAXINC=MAXAGE+1

'> nul forfiles /P \Dropbox\Supernote\Note /s /m .note /D -%MINAGE% /C "cmd /C if @isdir==FALSE 2> nul forfiles /M @file /D -%MAXINC% || > con cmd /c supernote-tool convert -t pdf -a @file @fname.pdf" robocopy \Dropbox\Supernote\EXPORT\Converted /e .pdf /move echo Process completed pause'

The pause at the end is just so the window is up in the morning so that I know it ran.

francescoboc commented 5 months ago

@FinbarArgus I've made some changes and are running through cron every 5 minutes https://gist.github.com/cwhittl/2e384fedc4aef449a87365d5a80340a2

Thanks! This is super handy!

cwhittl commented 5 months ago

I'm hoping to post a new version this evening.. Done some cool things with it that I haven't had a time to share.

cwhittl commented 5 months ago

Actually here it is.. I was using obsidian and I used the folder structure in SuperNote to create Tasks and also check for it already being attached to a note or not https://gist.github.com/cwhittl/21869e95b26f5705f9409330c751e784