#!/bin/bash ########################################################### # # isplit splits and combine files # # Made By : ibrahim riad (Heema) # ########################################################### ########################################################### # Main ########################################################### if [ $# -eq 0 ];then echo "" echo "Usage : isplit [option] filename" echo "option : -s split file to specified size" echo " -p split file to specified parts" echo " -c combine the files" echo " -w make windows batch file to combine the files in windows " echo "" exit fi if [ $# -eq 2 ];then filepath=$2 fi ########################################################### case "$1" in ########################################################### # Split file ########################################################### -s) echo -n "Enter desired size (MB) : " read size split -b "$size"m "$filepath" "$filepath". echo "$filepath" > $HOME/.ksplittemp ;; ########################################################### # Split file to specified parts ########################################################### -p) echo -n "Enter desired parts : " read parts info=$(ls -l $filepath | awk '{print $5}') partsize=$((($info/$parts)+1)) split -b "$partsize" "$filepath" "$filepath". echo "$filepath" > $HOME/.ksplittemp ;; ########################################################### # Combine the files ########################################################### -c) BASE=$(basename "$filepath" | cut -d . -f1) guess=$(cat $HOME/.ksplittemp) guessname=$(basename "$guess") echo -n "Do you want the name of the output to be $guessname (y/n) : " read answer if [ "$answer" == "y" ];then echo "" else echo -n "Enter output name : " read outputname cat "$BASE".* > "$outputname" fi cat "$BASE".* > "$guessname" ;; ########################################################### # Make windows batch file to combine the files in win$ ########################################################### -w) basefile=$(basename "$filepath" | cut -d . -f1) guessing=$(cat $HOME/.ksplittemp) guessingname=$(basename $guessing) echo -e "@ echo off\n" > winbatch.bat echo -e "clr\n" >> winbatch.bat echo -e "\n" >> winbatch.bat echo -e "copy /B $basefile.a* $guessingname \n" >> winbatch.bat echo -e "\n" >> winbatch.bat echo -e "echo on\n" >> winbatch.bat ;; *) echo -e "\033[0;31mThis format is not supported\033[0m" ;; esac