Guest User

batch.sh

a guest
Oct 26th, 2016
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. #!/bin/bash
  2. FILENAME_IN="$1"
  3. FILENAME_OUT="$1.new"
  4. rm $FILENAME_OUT
  5. while IFS='' read -r line || [[ -n "$line" ]]; do
  6. LINE=$line
  7. NEWLINE=''
  8.  
  9. if [[ $line == *"custom_viewport_width"* ]]
  10. then
  11. CUSTOM_VIEWPORT_WIDTH=$(echo "$line" | sed 's/custom_viewport_width = "\(.*\)"/\1/')
  12. NEWLINE='custom_viewport_width = "'$((CUSTOM_VIEWPORT_WIDTH * 2/3))'"';
  13. fi
  14.  
  15. if [[ $line == *"custom_viewport_height"* ]]
  16. then
  17. CUSTOM_VIEWPORT_HEIGHT=$(echo "$line" | sed 's/custom_viewport_height = "\(.*\)"/\1/')
  18. NEWLINE='custom_viewport_height = "'$((CUSTOM_VIEWPORT_HEIGHT * 2/3))'"';
  19. fi
  20.  
  21. if [[ $line == *"custom_viewport_x"* ]]
  22. then
  23. CUSTOM_VIEWPORT_X=$(echo "$line" | sed 's/custom_viewport_x = "\(.*\)"/\1/')
  24. NEWLINE='custom_viewport_x = "'$((CUSTOM_VIEWPORT_X * 2/3))'"';
  25. fi
  26.  
  27. if [[ $line == *"custom_viewport_y"* ]]
  28. then
  29. CUSTOM_VIEWPORT_Y=$(echo "$line" | sed 's/custom_viewport_y = "\(.*\)"/\1/')
  30. NEWLINE='custom_viewport_y = "'$((CUSTOM_VIEWPORT_Y * 2/3))'"'
  31. fi
  32.  
  33. if [[ $NEWLINE == "" ]]
  34. then
  35. NEWLINE=$LINE
  36. fi
  37. echo "$NEWLINE" >> $FILENAME_OUT
  38. done < "$1"
Add Comment
Please, Sign In to add comment