From 19290f54dbf6a8a025b9974a0535a80e3091f806 Mon Sep 17 00:00:00 2001 From: AzizLight Date: Tue, 6 Oct 2009 11:16:02 +0200 Subject: [PATCH] Added bin directory with some scripts inside. --- bin/ci | 70 ++++++++++++++++++++++++++++++++++++++++++++++++ bin/extract | 22 +++++++++++++++ bin/musiclassics | 51 +++++++++++++++++++++++++++++++++++ bin/now | 2 ++ 4 files changed, 145 insertions(+) create mode 100755 bin/ci create mode 100755 bin/extract create mode 100755 bin/musiclassics create mode 100755 bin/now diff --git a/bin/ci b/bin/ci new file mode 100755 index 0000000..bd2af49 --- /dev/null +++ b/bin/ci @@ -0,0 +1,70 @@ +#!/bin/bash +# This is where the CodeIgniter main folder is +ci_dir="/Users/aziz/Sites/source/CodeIgniter_1.7.2" + +# The current date used for the default project name if no project name is submited +date=`date +"%Y-%m-%d_%H-%M-%S"` + +# Create the main project folder +if [ -z $1 ] +then + read -p "Choose a name for your project: [Default: ci-$date]" project_name + if [ -z $project_name ] + then + \cp -R $ci_dir ./ci-$date + project_name=ci-$date + else + \cp -R $ci_dir ./$project_name + project_name=$project_name + fi +else + let "folder_exists= 1" + while [ $folder_exists -eq 1 ] + do + if [ -d $1 ] + then + echo 'This directory already exists' + read -p "Choose a name for your project: [Default: ci-$date]" project_name + if [ -z $project_name ] + then + let "folder_exists= 0" + \cp -R $ci_dir ./ci-$date + project_name=ci-$date + else + if [ -d $project_name ] + then + let "folder_exists= 1" + else + let "folder_exists= 0" + \cp -R $ci_dir ./$project_name + project_name=$project_name + fi + fi + else + let "folder_exists= 0" + \cp -R $ci_dir $1 + project_name=$1 + fi + done +fi + +# Ask the user if he wants to move the application folder outside the system folder +dir=`pwd` +echo "Project folder created in $dir/" +read -p "Do you want to move the application? [Default: y]"$'\n'"[y/n] " -n 1 choice +if [ -z $choice ] || [ $choice = 'y' ] +then + \cd "$project_name" + mv system/application application + \cd - + echo -e "\nApplication folder moved outside the system folder\n" +fi +read -p "Do you want to create a public folder in the application root? [Default: y]"$'\n'"[y/n] " -n 1 choice +if [ -z $choice ] || [ $choice = 'y' ] +then + \cd "$project_name" + \mkdir -p public/css public/js + \cd - + echo -e "\nplublic folder successfully generated" +fi +echo -e "\nProject generated successfully in $dir/$project_name" \ No newline at end of file diff --git a/bin/extract b/bin/extract new file mode 100755 index 0000000..933fdac --- /dev/null +++ b/bin/extract @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Extract about anything + +if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xvjf $1 ;; + *.tar.gz) tar xvzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) unrar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xvf $1 ;; + *.tbz2) tar xvjf $1 ;; + *.tgz) tar xvzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via >extract<" ;; + esac +else + echo "'$1' is not a valid file" +fi \ No newline at end of file diff --git a/bin/musiclassics b/bin/musiclassics new file mode 100755 index 0000000..c1d5506 --- /dev/null +++ b/bin/musiclassics @@ -0,0 +1,51 @@ +#!/usr/bin/env php -q + 1) ? end($extension) : $extension = ''; + + // extension verification + if (!in_array($extension, $allowed_extensions)) + continue; + + // put new file names in $match array + preg_match('/^\d+/',$file,$matches); + + if (empty($extension)) + { + if (file_exists($dir_name.'_'.$matches[0].'.wma')) + continue; + rename($file, $dir_name.'_'.$matches[0].'.wma'); + } + else + { + if (file_exists($dir_name.'_'.$matches[0].'.'.$extension)) + continue; + rename($file, $dir_name.'_'.$matches[0].'.'.$extension); + } + } + } +} +?> \ No newline at end of file diff --git a/bin/now b/bin/now new file mode 100755 index 0000000..0f53dc3 --- /dev/null +++ b/bin/now @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +puts Time.now.localtime.strftime("%Y-%m-%d_%H-%M-%S") \ No newline at end of file