Skip to content

Instantly share code, notes, and snippets.

@truekonrads
Created February 10, 2017 18:51
Show Gist options
  • Select an option

  • Save truekonrads/b5c233b1bcde5f01bfe4747c83dd51c7 to your computer and use it in GitHub Desktop.

Select an option

Save truekonrads/b5c233b1bcde5f01bfe4747c83dd51c7 to your computer and use it in GitHub Desktop.
Bulk remove sheet protection from xlsx
C=`pwd`;for i in *.xlsx; do cd $C; b=$(basename "$i" .xlsx); rm -rf "$b"; mkdir "$b"; unzip -d "$b" "$i"; find "$b" -name sheet*.xml -print0 | xargs -0 perl -p -i -e 's!<sheetProtect\w+ .+?/>!!g' ; find "$b" -name \*.bak -exec rm {} \; ; cd "$b"; zip -r "../done/$b - unprotected.xlsx" .; cd "$C"; rm -rf "$b"; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment