Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function cpfile() {
- sourcefile="$1"
- destinationDir="$2"
- filename=$( basename "$sourcefile" )
- extension="${filename##*.}"
- filename="${filename%.*}"
- alreadyExist=0
- if [ -f "$destinationDir/$filename.$extension" ] # file exist in destination
- then
- filename=$( printf "%s_new.%s" "$filename" "$extension" )
- alreadyExist=1
- else
- filename="$filename.$extension"
- fi
- if [[ "$3" == "--move" ]]
- then mv "$sourcefile" "$destinationDir/$filename"
- else
- if (( "$alreadyExist" == 0 )) ; then
- cp "$sourcefile" "$destinationDir/$filename"
- fi
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement