download_data.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #!/bin/bash
  2. # Copyright 2016 The TensorFlow Authors All Rights Reserved.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. # ==============================================================================
  16. # Example:
  17. #
  18. # download_dataset.sh datafiles.txt ./tmp
  19. #
  20. # will download all of the files listed in the file, datafiles.txt, into
  21. # a directory, "./tmp".
  22. #
  23. # Each line of the datafiles.txt file should contain the path from the
  24. # bucket root to a file.
  25. ARGC="$#"
  26. LISTING_FILE=push_datafiles.txt
  27. if [ "${ARGC}" -ge 1 ]; then
  28. LISTING_FILE=$1
  29. fi
  30. OUTPUT_DIR="./"
  31. if [ "${ARGC}" -ge 2 ]; then
  32. OUTPUT_DIR=$2
  33. fi
  34. echo "OUTPUT_DIR=$OUTPUT_DIR"
  35. mkdir "${OUTPUT_DIR}"
  36. function download_file {
  37. FILE=$1
  38. BUCKET="https://storage.googleapis.com/brain-robotics-data"
  39. URL="${BUCKET}/${FILE}"
  40. OUTPUT_FILE="${OUTPUT_DIR}/${FILE}"
  41. DIRECTORY=`dirname ${OUTPUT_FILE}`
  42. echo DIRECTORY=$DIRECTORY
  43. mkdir -p "${DIRECTORY}"
  44. curl --output ${OUTPUT_FILE} ${URL}
  45. }
  46. while read filename; do
  47. download_file $filename
  48. done <${LISTING_FILE}