Last active
July 12, 2017 12:25
-
-
Save ferthalangur/00ffe1155a85040147d5e3b692547b0e to your computer and use it in GitHub Desktop.
Download all Free Microsoft Ebooks (*nix Script)
This file contains 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 | |
# | |
# Download Free Microsoft Ebooks | |
# ------------------------------ | |
# Eric Ligman has made a large number of Microsoft Ebooks available for free, | |
# no strings attached. He provided a Power Shell script, but not a /(Li|U)n[iu]x/ script. | |
# See: https://blogs.msdn.microsoft.com/mssmallbiz/2017/07/11/largest-free-microsoft-ebook-giveaway-im-giving-away-millions-of-free-microsoft-ebooks-again-including-windows-10-office-365-office-2016-power-bi-azure-windows-8-1-office-2013-sharepo/ | |
# ... yes, that's a sick URL that needs shortening: | |
# See: http://bit.ly/2tHlCY5 for details | |
#============================================================================== | |
# Author: Rob Jenson :: rbj@spotch.com :: https://github.com/ferthalangur | |
# Date: July 12, 2017 | |
# License: Apache 2.0 | |
# Source: https://gist.github.com/ferthalangur/00ffe1155a85040147d5e3b692547b0e | |
#============================================================================== | |
# Copyright [2017] [Robert B. Jenson] | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
#============================================================================== | |
# Usage: | |
# (1) Download this script to a new directory with plenty of space | |
# (2) Read this script to be sure that I'm not trying to hack your system | |
# and adjust any settings you prefer | |
# (3) chmod +x ./download_all_ebooks.bash | |
# (4) . ./download_all_ebooks.bash | |
#============================================================================== | |
# Requirements: bash, wget installed and in your path | |
#============================================================================== | |
# Caveats: | |
# (1) As of this writing, 360 files, 3.5 Gb. Eric Ligman controls the list | |
# file with the documents. If he changes format, deletes the file, etc. | |
# this breaks. Check one of the links above. | |
# (2) Filenames are downloaded and named what they are named on the download | |
# servers. Some of the filenames are meaningless, some of them have spaces | |
# in them. Renaming files, changing the spaces to underscores, removing | |
# shell metacharacters, etc. should be done, but I didn't. Send me a PR | |
# if you do this and improve it. | |
# (3) If you run this script multiple times, you'll get multiple copies of each | |
# file. I think that there is a wget flag to clobber existing filenames instead | |
# of creating a .1 or .2 ... file. | |
# (4) Tested on my desktop Mac and not elsewhere. It should not break anything, | |
# but Caveat Emptor. | |
#============================================================================== | |
# This is the URL for the list of files to be pulled | |
SOURCEFILE="${SOURCEFILE:-http://ligman.me/2sZVmcG}" | |
# Change LISTONLY to "yes" if you want to stop to review or edit the | |
# download file before using it. This will end the script, but you can run it | |
# again. | |
LISTONLY="${LISTONLY:-no}" | |
# | |
LISTFILE="{LISTFILE:-ebook-list.txt}" | |
# If you have wget in some place outside of your path you can override on the | |
# command line. e.g., WGET="/weird/bin/location/wget" ./download_all_ebooks.bash | |
WGET="${WGET:-wget}" | |
# Again, if you want to override, easiest way is on the command line environment | |
# WGETFLAGS="silent" ./download_all_ebooks.bash | |
WGETFLAGS="${WGETFLAGS:---verbose --trust-server-names}" | |
#============================================================================== | |
# Nothing to modify below here | |
#============================================================================== | |
mv -vf "${SOURCEFILE}" "${SOURCEFILE}.bak" | |
mv -vf "${LISTFILE}" "${LISTFILE}.bak" | |
"${WGET}" ${WGETFLAGS} -O - "${SOURCEFILE}" | grep -E -v 'MSFT eBooks' > "${LISTFILE}" | |
if [ "${PAUSE}" == "yes" ] | |
then | |
echo "Pausing (stopping) script. Examine ${LISTFILE} and then run again." | |
exit 0 | |
fi | |
"${WGET}" ${WGETFLAGS} --input-file="${LISTFILE}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment