Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- OUTPUT_PATH="./output/"
- INPUT_PATH="./input/"
- FORCE=false
- function show_help
- {
- echo "Usage:"
- echo " -h - show help:"
- echo " -i path - set input path (default='./')"
- echo " -o path - set output path (default='./')"
- echo " -f - force move - removes name-colliding files from output folder"
- }
- while getopts "fhi:o:" opt; do
- case "$opt" in
- h|\?)
- show_help
- exit 0
- ;;
- i) INPUT_PATH=$OPTARG
- ;;
- o) OUTPUT_PATH=$OPTARG
- if [[ ! -d $OUTPUT_PATH ]]; then
- echo "ERROR: Specified output path is not a directory"
- exit 1
- fi
- ;;
- f) FORCE=true
- ;;
- esac
- done
- if [[ ! -d $INPUT_PATH ]]; then
- echo "ERROR: Specified input path is not a directory"
- exit 1
- fi
- mkdir -p $OUTPUT_PATH
- I=$((-1))
- for f in $INPUT_PATH/*
- do
- I=$((I+1))
- if [[ -e $OUTPUT_PATH/$I ]]; then
- if [ $FORCE == true ]; then
- echo F
- rm -rf $OUTPUT_PATH/$I
- else
- echo NF
- continue
- fi
- fi
- mv $f $OUTPUT_PATH/$I
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement