convert_folder.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 <<< "${scene}"
  33. scene_folder=${ADDR[-1]}
  34. # get output expected path
  35. output_scene_path=$output_folder/$scene_folder
  36. IFS='.' read -ra ADDR <<< "${file}"
  37. filename_without_ext=${ADDR[0]}
  38. outfile="${filename_without_ext}.${ext}"
  39. # check if filename contains
  40. if [[ "$file" == ${prefix}* ]]; then
  41. echo ./build/main/rawls_convert --image ${filename_fixed} --outfile ${output_scene_path}/${outfile}
  42. fi
  43. done
  44. done
  45. done