this makes a bkp with timestamp of an entire dierctory tree of a NetBeans project. (and optionaly the database)
Code:
#!/bin/bash
if [ -z $2 ]; then
tar -cjf "$1-`date +%a-%d-%m-%y_[%H-%M]`.tar.bz2" "$1"
else
bkpData="$2-`date +%a-%d-%m-%y_[%H-%M]`.sql"
mysqldump -u root -p30359651 $2 > $bkpData
tar -cjf "$1-`date +%a-%d-%m-%y_[%H-%M]`.tar.bz2" "$1" $bkpData
rm $bkpData
resulting in somthing like:
NetBeans_Projects-Mon-28-01-08_[21-40].tar.bz2
the next script I made for transpassing the entire directory structure of a NEtBEans project WITHOUT the configurations files that wouldn't let me load the project on a diferent machine.
Code:
#!/bin/bash
# La idea es importar los *.java a otro arbol igual y ver si el netbeans puede utilizarlo
# $1 debe ser el arbol importado.
# $2 el destino. si esta vacio (lo crea sina archivos de configuracion) si no deberia tener una estructura de directorios igual.
find "$1" -type d > Temp_Project_Dirs
grep -v /nbproject Temp_Project_Dirs | grep -v /dist | grep -v /build > Project_Dirs
Num_dirs=`wc -l Project_Dirs | cut -d" " -f1`
for i in `seq 1 $Num_dirs` ; do
head -n $i Project_Dirs | tail -1 > Project_Dirs_linea
linea=`cat Project_Dirs_linea`
find "$linea" -type f -iname "*.java" -maxdepth 1 > Project_Dirs_content
find "$linea" -type f -iname "*.form" -maxdepth 1 > Project_Dirs_forms
find "$linea" -type f -iname "*.gif" -maxdepth 1 > Project_Dirs_images
find "$linea" -type f -iname "*.jpg" -maxdepth 1 > Project_Dirs_images
find "$linea" -type f -iname "*.jar" -maxdepth 1 > Project_Dirs_libs
mkdir -p "import/$linea"
Num_files=`wc -l Project_Dirs_content | cut -d" " -f1`
for j in `seq 1 $Num_files` ; do
file=`head -n $j Project_Dirs_content | tail -1`
cp "$file" "import/$linea/"
done
Num_forms=`wc -l Project_Dirs_forms | cut -d" " -f1`
for j in `seq 1 $Num_forms` ; do
file=`head -n $j Project_Dirs_forms | tail -1`
cp "$file" "import/$linea/"
done
Num_images=`wc -l Project_Dirs_images | cut -d" " -f1`
for j in `seq 1 $Num_images` ; do
file=`head -n $j Project_Dirs_images | tail -1`
cp "$file" "import/$linea/"
done
Num_libs=`wc -l Project_Dirs_libs | cut -d" " -f1`
for j in `seq 1 $Num_libs` ; do
file=`head -n $j Project_Dirs_libs | tail -1`
cp "$file" "import/$linea/"
done
done
rm Project_Dirs_forms Temp_Project_Dirs Project_Dirs_linea Project_Dirs Project_Dirs_content Project_Dirs_images
the important parts for you may be:
Code:
find "$1" -type d > Temp_Project_Dirs
grep -v /nbproject Temp_Project_Dirs | grep -v /dist | grep -v /build > Project_Dirs # IF YOU WANT TO EXCLUDE SOME DIRS TOO
Num_dirs=`wc -l Project_Dirs | cut -d" " -f1`
for i in `seq 1 $Num_dirs` ; do
head -n $i Project_Dirs | tail -1 > Project_Dirs_linea
linea=`cat Project_Dirs_linea`
find "$linea" -type f -iname "*.java" -maxdepth 1 > Project_Dirs_content #ONLY WHAT YOU WANT -> "*.JAVA" for me
Num_files=`wc -l Project_Dirs_content | cut -d" " -f1`
for j in `seq 1 $Num_files` ; do
file=`head -n $j Project_Dirs_content | tail -1`
cp "$file" "import/$linea/"
done
done
rm Temp_Project_Dirs Project_Dirs_linea Project_Dirs Project_Dirs_content
the duplicated tree will reside in ./import/<duplicated tree>
you should mix them to add the timestam thing..
also you could relace:
Quote:
find "$linea" -type f -iname "*.java" -maxdepth 1 > Project_Dirs_content #ONLY WHAT YOU WANT -> "*.JAVA" for me
Num_files=`wc -l Project_Dirs_content | cut -d" " -f1`
for j in `seq 1 $Num_files` ; do
file=`head -n $j Project_Dirs_content | tail -1`
cp "$file" "import/$linea/"
done
|
for
Quote:
find "$linea" -type f -iname "*.java" -maxdepth 1 -exec cp {} "import/$linea/" \; #ONLY WHAT YOU WANT -> "*.JAVA" for me
|