Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- rename()
- {
- local old_path=$1 char=$2
- echo "$old_path" | sed 's/^\([^.]*\)/\1'$char'/'
- }
- find_name()
- {
- local catalog_name=$1 filename=$2
- found=0
- files=`ls "$catalog_name"`
- for file in files
- do
- if [ $file = $filename ]
- then
- found=1
- fi
- done
- echo "$found"
- }
- catalog_name=$1
- archive_name=$2
- if [ ! -d $catalog_name ]
- then
- mkdir $catalog_name
- fi
- count=0
- for extension in $@
- do
- count=$(( $count + 1 ))
- if [ $count -ge 3 ]
- then
- paths=`find ~/techprog -name "*.$extension"`
- for path in $paths
- do
- temp="$path"
- src_filename=`basename "$path"`
- while [ `find_name "$catalog_name" "$src_filename"` -gt 0 ]
- do
- new_path=`rename "$path" "_"`
- mv "$path" "$new_path"
- path="$new_path"
- src_filename=`basename "$path"`
- done
- cp "$path" "$catalog_name"
- done
- fi
- done
- tar -czf $archive_name "$catalog_name"
- echo "done"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement