working on OS X 10.8.3, have part of what I want working, hoping for help with the rest
#!/bin/bash
# script accepts a path to base dir - base path to extract
# also accepts second param - archive /xys/there/usefulLib-version-3.2.1.zip
# 1. cd to base
# 2. get name path of file, 'useful-lib-version-3.2.1.zip'
# 3. strip away extn and -._ spaces so its 'usefulLibversion321' if possible make init char capital of each token (from second) before removing the separator like 'usefulLibVersion321'
# 4. if this folder exists in base then add 1 or 2 or 3 till we get a new folder name, create that. cd to that new folder
# 5. give extract command to original file here (like jar xp -file- or other)
cd $1
file1=$2
file1fullname=$(basename $file1)
file1name=${file1fullname%.*}
echo ${file1fullname}
echo ${file1name}
file1sname=${file1name//./}
file1sname=${file1sname//-/}
file1sname=${file1sname//_/}
file1sname=${file1sname// /}
echo ${file1sname}
mkdir ${file1sname}
cd ${file1sname}
#could use other extract command, i know this one of java
jar xf $2
I need help with point 4.
Motivation : quickly expand the many jars and other archives that I download. some times get many .jar files with spring and other frameworks and utilities.