convert_folder.sh 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #! /bin/bash
  2. if [ -z "$1" ]
  3. then
  4. echo "No argument supplied"
  5. echo "Need folder argument"
  6. exit 1
  7. fi
  8. if [ -z "$2" ]
  9. then
  10. echo "No argument supplied"
  11. echo "Need output extension"
  12. exit 1
  13. fi
  14. if [ -z "$3" ]
  15. then
  16. echo "No argument supplied"
  17. echo "Need output folder"
  18. exit 1
  19. fi
  20. main_folder=$1
  21. prefix="p3d_"
  22. ext=$2
  23. output_folder=$3
  24. for folder in $(ls -d -- ${main_folder}*/)
  25. do
  26. for scene in $(ls -d $folder)
  27. do
  28. for file in $(ls $folder)
  29. do
  30. filename=$folder$file
  31. filename_fixed=${filename//\/\//\/}
  32. IFS='.' read -ra ADDR <<< "${file}"
  33. filename_without_ext=${ADDR[0]}
  34. outfile="${filename_without_ext}.${ext}"
  35. # check if filename contains
  36. if [[ "$file" == ${prefix}* ]]; then
  37. ./main/rawls_convert --image ${filename_fixed} --outfile ${output_folder}/${outfile}
  38. fi
  39. done
  40. done
  41. done