Created
August 29, 2014 20:09
-
-
Save bl4ckb1rd/f45881fa6a91bab720b3 to your computer and use it in GitHub Desktop.
Convert files with SYLK format into csv with libreoffice
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 | |
# Path on with find search | |
FINDPATH="$(pwd)/files/" | |
# Extension to search | |
FILEEXTENSION="*.xls" | |
# Check if libreoffice it is installed | |
LIBREOFFICE=$(which libreoffice) | |
if [[ $LIBREOFFICE == *not* ]] | |
then | |
echo "Dont found libreoffice installed, exit"; | |
exit | |
fi | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
for f in $(find $FINDPATH -type f -iname $FILEEXTENSION) | |
do | |
DIRNAME=$(dirname "$f") | |
BASENAME=$(basename "$f") | |
cd "$DIRNAME" | |
$LIBREOFFICE --headless --convert-to csv:"Text - txt - csv (StarCalc)" "$BASENAME" | |
done | |
IFS=$SAVEIFS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment