add script to import org files
This commit is contained in:
parent
115f92a6ba
commit
b9567f132d
1 changed files with 55 additions and 0 deletions
55
import.sh
Executable file
55
import.sh
Executable file
|
@ -0,0 +1,55 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# importe les fichiers org modifiés pour une publication
|
||||||
|
#
|
||||||
|
# Copyright (C) 2022 rick G. <rick@gnous.eu>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify it under
|
||||||
|
# the terms of the GNU General Public License as published by the Free Software
|
||||||
|
# Foundation, either version 3 of the License, or (at your option) any later
|
||||||
|
# version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License along with
|
||||||
|
# this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# couleurs
|
||||||
|
red="\e[31m"
|
||||||
|
blue="\e[34m"
|
||||||
|
green="\e[32m"
|
||||||
|
reset="\e[0m"
|
||||||
|
|
||||||
|
origin="$HOME/Documents/partages/"
|
||||||
|
folders="moocs confs"
|
||||||
|
dest="nec/"
|
||||||
|
|
||||||
|
check ()
|
||||||
|
{
|
||||||
|
tmp=${1/$origin/$dest} # nouveau chemin
|
||||||
|
filename=${1/$origin/} # on garde le chemin dans le dossier d'origine
|
||||||
|
pathfile=$(dirname $filename) # chemin sans le nom du fichier
|
||||||
|
|
||||||
|
diff -q $1 $tmp 2> /dev/null
|
||||||
|
case $? in
|
||||||
|
1) echo -e "[$blue C $reset] Copie de $1 vers $tmp."
|
||||||
|
cp $1 $tmp
|
||||||
|
;;
|
||||||
|
2) echo -e "[$green A $reset] Nouveau fichier: $filename"
|
||||||
|
mkdir -p $dest$pathfile # on créé le dossier s'il n'existe pas
|
||||||
|
cp $1 $tmp
|
||||||
|
;;
|
||||||
|
*) echo -e "[$red R $reset] $filename non modifié."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
for i in ${folders}
|
||||||
|
do
|
||||||
|
for j in $(find "$origin$i" -type f -iname "*.org")
|
||||||
|
do
|
||||||
|
check $j
|
||||||
|
done
|
||||||
|
done
|
Loading…
Reference in a new issue