Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have to create several projects with a folder structure, in those folders will be some files.

Every time I have to create a project, I have to create a folder, copy folders and files from another one and paste on the new folder.

I want to make this as easy as possible and thought about using a terminal command to do so, like:

projects create "project_name"

Ubuntu will then create the folder and files on the new project folder.

Thanks in advance for any help.

EDIT:

I use a PHP framework, CodeIgniter, I need to replicate its structure to other folders, I need to make it as dynamic as possible.

EDIT:

What I need is something like this?

codeigniter create "project_name"

When I press Enter, it will copy all files and folders from a defined location and paste it on a new folder, also on a defined location with the Project_name. The location must be defined because it needs to be on a Apache htdocs folder

share|improve this question
    
It seems rather simple, but the information are less than needed to give a real answer. –  enzotib Aug 11 '11 at 20:03
    
what else do you need? –  Gerep Aug 11 '11 at 20:04
    
For example, the new project folder structure can be simply copied from a skeleton, with some modification? And what modication you need? Please, put new information directly in the question. –  enzotib Aug 11 '11 at 20:08
    
ok, project_folder will be folder where new project will be created, project name will be name for that project (ie. /"project_folder"/"project_name"/ ?), or it will echo name to some file or what ? please specify. It looks like simple bash script, will type it if noone else will, but specify this first –  Denwerko Aug 11 '11 at 20:08

1 Answer 1

up vote 2 down vote accepted

You can put together a simple script to do this.

The following will do what you want assuming the original codeignitor source is in /usr/local/src/codeignitor

The code will need to be saved into a file called codeignitor in your PATH. An ideal place would be to create a folder called bin in your home directory and save it in there. The permissions will need to be set to allow execute permissions.

To create a new folder called new_project, you will run the command as

codeignitor create new_project

The script is as basic as it can be so will need to be extended if this is the sort of solution you need, here is the code:

#!/bin/bash

src='/usr/local/src/codeignitor/'

cmd=$1
dest=$2

case $cmd in
    create )
        cp -av $src $dest
        ;;
    * )
        exit 1
        ;;
esac
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.