Created
May 8, 2014 17:38
-
-
Save hell0again/1f5c9f6f1f84fb1690ec to your computer and use it in GitHub Desktop.
xlsxをunzipしてxmllint formatして再度zipにする
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
## xlsxをunzipしてxmllint formatして再度zipしても読める事を確認 | |
# FLATTEN2の中身を直接書き換えて最後のzipコマンドを実行してもxlsxとして読める | |
ORIGINAL=time_sample.xlsx | |
FLATTEN1=flatten | |
FLATTEN2=reflatten | |
REZIP1=flatten.xlsx | |
REZIP1=reflatten.xlsx | |
rm -rf ${REZIP1} ${REZIP2} ${FLATTEN1} ${FLATTEN2} | |
unzip ${ORIGINAL} -d ${FLATTEN1} | |
cd ${FLATTEN1} | |
zip ../${REZIP1} $(find .) | |
unzip ../${REZIP1} -d ../${FLATTEN2} | |
cd ../${FLATTEN2} | |
for i in $( find . -name "*.xml" -o -name "*.rels"); do | |
(rm $i; xmllint --format - >$i) <$i | |
done | |
zip ../${REZIP2} $(find .) | |
cd ../ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment