Skip to content

Commit

Permalink
Added bin directory with some scripts inside.
Browse files Browse the repository at this point in the history
  • Loading branch information
AzizLight committed Oct 6, 2009
1 parent c7f3123 commit 19290f5
Show file tree
Hide file tree
Showing 4 changed files with 145 additions and 0 deletions.
70 changes: 70 additions & 0 deletions 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"
22 changes: 22 additions & 0 deletions 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
51 changes: 51 additions & 0 deletions bin/musiclassics
@@ -0,0 +1,51 @@
#!/usr/bin/env php -q
<?php
// Working directory
$dir = (empty($argv[1])) ? '.' : './'.$argv[1];

// Allowed extensions
$allowed_extensions = array(
'wma'
);

if (is_dir($dir))
{
if ($handle = opendir($dir))
{
while (($file = readdir($handle)) !== FALSE) {

if (preg_match('/^\d+-\d+_\d+\.wma$/',$file) || !is_file($file) || !preg_match('/^\d+/',$file))
continue;

// directory name
$dir_name = explode('/',realpath($file));
$previous_to_last = count($dir_name) - 2;
$dir_name = $dir_name[$previous_to_last];

// Extension
$extension = explode('.',$file);
$extension = (count($extension) > 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);
}
}
}
}
?>
2 changes: 2 additions & 0 deletions bin/now
@@ -0,0 +1,2 @@
#!/usr/bin/env ruby
puts Time.now.localtime.strftime("%Y-%m-%d_%H-%M-%S")

0 comments on commit 19290f5

Please sign in to comment.