You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #!/bin/bash
-
- usage () {
- echo "$0: [-n] <source directory> <target directory>"
- echo
- echo "Convert filenames to appropriate format for training"
- echo
- echo "-n Dry run"
- exit 1
- }
-
- DRY_RUN=0
-
- while getopts "nh" arg; do
- case $arg in
- h)
- usage
- ;;
- n)
- DRY_RUN=1
- ;;
- esac
- done
- shift $((OPTIND-1))
-
- if [[ "$#" != "2" ]]
- then
- echo "error: Missing directory parameters."
- echo "See -h for help"
- exit 1
- fi
-
- IN=$1;shift
- OUT=$1;shift
-
- mkdir -p $OUT/{images,labels}
-
- for dir in $(for dir in $IN/*; do basename "$dir"; done)
- do
- for file in $IN/$dir/*.orig.jpg
- do
- if [[ "$DRY_RUN" == "1" ]]
- then
- echo cp -a --reflink=auto $file $OUT/images/"$dir"_"$(basename $file|sed 's/\.orig\././')"
- else
- cp -a --reflink=auto $file $OUT/images/"$dir"_"$(basename $file|sed 's/\.orig\././')"
- fi
- done
- for file in $IN/$dir/*.coloured.jpg
- do
- if [[ "$DRY_RUN" == "1" ]]
- then
- echo cp -a --reflink=auto $file $OUT/labels/"$dir"_"$(basename $file|sed 's/\.coloured\././')"
- else
- cp -a --reflink=auto $file $OUT/labels/"$dir"_"$(basename $file|sed 's/\.coloured\././')"
- fi
- done
- done
|