]>
Wikimedia Canada | Git repositories - eccc_to_commons.git/blob - eccc_fixer.sh
3 # eccc_fixer.sh - Create Environment and Climate change Canada historical data
5 # Copyright (C) 2019-2020 Pierre Choffet
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 if [ -z "${SOURCE}" ]||[ -z "${DESTINATION}" ]||[ -d "${DESTINATION}" ]
27 echo 'Fix XMLs provided by Environment and Climate change Canada'
28 echo 'Usage: eccc_fixer.sh <source folder> <destination folder>'
30 echo 'To prevent wrong usage, <destination folder> must not exist.'
34 # Recreate folders structure
35 while IFS
= read -r -d '' -u 9
37 mkdir -p -- "${DESTINATION}/$(realpath --relative-to "${SOURCE}" "${REPLY}")"
39 done 9< <( find "${SOURCE}" -type d
-print0 )
41 # Transform original files
42 while IFS
= read -r -d '' -u 9
44 xmlstarlet
tr eccc_fixer.xslt
"${REPLY}" > "${DESTINATION}/$(realpath --relative-to "${SOURCE}" "${REPLY}")"
45 done 9< <( find "${SOURCE}" -type f
-name '*.xml' -print0 )