Guest User

Untitled

a guest
Dec 12th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #
  4. # Generate the Source file using: find -type f > filelist.txt
  5. #
  6.  
  7. if [ $# -lt 1 ];
  8. then
  9. echo "Usage: $0 dl-filelist.txt [placeholder]"
  10. else
  11. IFS=$'\n'
  12. FILELIST=$1
  13. PLACEHOLDER='placeholder.jpg'
  14.  
  15. if [ $# -eq 2 ];
  16. then
  17. PLACEHOLDER=$2
  18. fi
  19.  
  20. echo "Compiling file list..."
  21. numFiles=`cat $FILELIST | wc -l`
  22. currFile=0
  23. skipFile=0
  24.  
  25. for i in `cat $FILELIST`;
  26. do
  27. if [ -e $i ] ;
  28. then
  29. ((skipFile++))
  30. else
  31. echo -ne 'Copying file' $currFile 'of ' $numFiles '...\r'
  32. mkdir -p `dirname $i`
  33. cp $PLACEHOLDER $i
  34. ((currFile++))
  35. fi
  36. done
  37.  
  38. echo ""
  39. echo "$numFiles total files."
  40. echo "$currFile files copied."
  41. echo "$skipFile files skipped."
  42. echo "Done!"
  43. fi
Add Comment
Please, Sign In to add comment