From e6efa0a8f5554fef902e4af77cb0fa05593de5f2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Thu, 2 Feb 2017 12:06:32 +0100
Subject: [PATCH 01/11] Create classifier.sh
I wish to suggest a different system to put recovered files that testdisk users could find useful. Feel free to integrate it in testdisk if you want. Either as a new option for the comand or as a substitute for the current recup_dir1, recup_dir2, recup_dir3 etc system.
---
classifier.sh | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
create mode 100644 classifier.sh
diff --git a/classifier.sh b/classifier.sh
new file mode 100644
index 00000000..a0b2f060
--- /dev/null
+++ b/classifier.sh
@@ -0,0 +1,20 @@
+## pvaldes 2017-01-27
+## This script examine the content of each file recovered by photorec and will put it in a directory
+## with other files of the same type, making much easier to find what we are looking for.
+## It the dir does not exist will be created automatically in the current working directory.
+
+## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to a new dir named Python/,
+## all makefiles to makefile/ all chunks of C++ files to C++, etc...
+
+for i in `find . -type f`; do
+ tipo=`file $i | awk '{gsub("/","-"); print $2}'`
+
+ if [ ! -d "../$tipo" ]
+ then
+ mkdir "../$tipo"
+ fi
+ mv -i $i ../$tipo/
+ tipo=""
+done
+
+exit 0
From 4bb987a56966fabe951963469ad72fa45376d3cf Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 13:31:37 +0100
Subject: [PATCH 02/11] Update classifier.sh
Working in the name of directories. Can specify more types of directories now.
---
classifier.sh | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/classifier.sh b/classifier.sh
index a0b2f060..abb40c76 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -3,18 +3,21 @@
## with other files of the same type, making much easier to find what we are looking for.
## It the dir does not exist will be created automatically in the current working directory.
-## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to a new dir named Python/,
-## all makefiles to makefile/ all chunks of C++ files to C++, etc...
+## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to a new dir named Python-script/,
+## all makefiles to makefile/ all chunks of C++ files to C++-source-ascii-text, etc...
+
+## 2017-02-04 name of the directories improved. Maybe too much verbose now?
for i in `find . -type f`; do
- tipo=`file $i | awk '{gsub("/","-"); print $2}'`
+ typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); if($6) print $2,$3,$4,$5,$6; else if($5) print $2,$3,$4,$5; else if($4) print $2,$3,$4; else if($3) print $2,$3; else print $2}'`;
- if [ ! -d "../$tipo" ]
+ if [ ! -d "../$typedir" ]
then
- mkdir "../$tipo"
+ mkdir "../$typedir"
fi
- mv -i $i ../$tipo/
- tipo=""
+ mv -i $i ../$typedir/
+ typedir=""
+
done
exit 0
From 33f5239767ab4adf63fff1126fed083bfa6bffbe Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:09:21 +0100
Subject: [PATCH 03/11] Update classifier.sh
Name of the directories improved. Support for further classification inside each group.
---
classifier.sh | 30 ++++++++++++++++++++----------
1 file changed, 20 insertions(+), 10 deletions(-)
diff --git a/classifier.sh b/classifier.sh
index abb40c76..36bbb1e6 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -3,21 +3,31 @@
## with other files of the same type, making much easier to find what we are looking for.
## It the dir does not exist will be created automatically in the current working directory.
-## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to a new dir named Python-script/,
-## all makefiles to makefile/ all chunks of C++ files to C++-source-ascii-text, etc...
+## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to subdirectories in a new dir named Python/,
+## all makefiles to makefile/ all chunks of C++ files to C++/, etc...
-## 2017-02-04 name of the directories improved. Maybe too much verbose now?
+## 2017-02-04 name of the directories improved. Support for further classification inside each group.
for i in `find . -type f`; do
- typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); if($6) print $2,$3,$4,$5,$6; else if($5) print $2,$3,$4,$5; else if($4) print $2,$3,$4; else if($3) print $2,$3; else print $2}'`;
+ parentdir=`file $i | awk '{gsub("/" , "-"); gsub("," , ""); print $2}'`;
+ typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); if($6) print $2,$3,$4,$5,$6; else if($5) print $2,$3,$4,$5; else if($4) print $2,$3,$4; else if($3) print $2,$3; else print $2}'`;
- if [ ! -d "../$typedir" ]
+ if [ ! -d "../$parentdir" ]
then
- mkdir "../$typedir"
- fi
- mv -i $i ../$typedir/
- typedir=""
-
+ mkdir "../$parentdir"
+ fi
+
+ if [[ $typedir == "$parentdir"* ]]
+ then
+ if [ ! -d "../$parentdir/$typedir" ]
+ then
+ mkdir "../$parentdir/$typedir"
+ fi
+ mv -i $i ../$parentdir/$typedir/
+ fi
+ typedir=""
+ parentdir=""
+
done
exit 0
From c6b4ad2b9f2645c3eb57fd2ca495001b4c11f5bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:12:12 +0100
Subject: [PATCH 04/11] Update classifier.sh
---
classifier.sh | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index 36bbb1e6..e73e91f6 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -16,8 +16,12 @@ for i in `find . -type f`; do
then
mkdir "../$parentdir"
fi
+
+ if [ "$typedir" == "$parentdir"]
+ mv -i $i ../$parentdir/
+ fi
- if [[ $typedir == "$parentdir"* ]]
+if [[ $typedir == "$parentdir"* ]]
then
if [ ! -d "../$parentdir/$typedir" ]
then
From 7441d6a05bc97313da0deb0e86222fb177ce8ac2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:13:21 +0100
Subject: [PATCH 05/11] Update classifier.sh
---
classifier.sh | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/classifier.sh b/classifier.sh
index e73e91f6..0d45f088 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -15,13 +15,14 @@ for i in `find . -type f`; do
if [ ! -d "../$parentdir" ]
then
mkdir "../$parentdir"
- fi
+ fi
if [ "$typedir" == "$parentdir"]
+ then
mv -i $i ../$parentdir/
- fi
+ fi
-if [[ $typedir == "$parentdir"* ]]
+ if [[ $typedir == "$parentdir"* ]]
then
if [ ! -d "../$parentdir/$typedir" ]
then
From 936a9b7b5df4c2174aac6e9c5d4846030d7403b6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:35:52 +0100
Subject: [PATCH 06/11] Update classifier.sh
Adding some notes explaining code
---
classifier.sh | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
diff --git a/classifier.sh b/classifier.sh
index 0d45f088..26af9c28 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -1,7 +1,6 @@
## pvaldes 2017-01-27
## This script examine the content of each file recovered by photorec and will put it in a directory
## with other files of the same type, making much easier to find what we are looking for.
-## It the dir does not exist will be created automatically in the current working directory.
## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to subdirectories in a new dir named Python/,
## all makefiles to makefile/ all chunks of C++ files to C++/, etc...
@@ -9,29 +8,34 @@
## 2017-02-04 name of the directories improved. Support for further classification inside each group.
for i in `find . -type f`; do
- parentdir=`file $i | awk '{gsub("/" , "-"); gsub("," , ""); print $2}'`;
+ classdir=`file $i | awk '{gsub("/" , "-"); gsub("," , ""); print $2}'`;
typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); if($6) print $2,$3,$4,$5,$6; else if($5) print $2,$3,$4,$5; else if($4) print $2,$3,$4; else if($3) print $2,$3; else print $2}'`;
- if [ ! -d "../$parentdir" ]
+## It the dir does not exist, create it in ../
+ if [ ! -d "../$classdir" ]
then
- mkdir "../$parentdir"
+ mkdir "../$classtdir"
fi
- if [ "$typedir" == "$parentdir"]
+## If the names of dir class (parent) and type (subdir) are the same, do not create subdirs
+## and move files directly to the directory class
+ if [ "$typedir" == "$classdir"]
then
- mv -i $i ../$parentdir/
+ mv -i $i ../$classdir/
fi
-
- if [[ $typedir == "$parentdir"* ]]
+## Create subdirs and and move all archives of its appropriate class and type.
+ if [[ $typedir == "$classdir"* ]]
then
- if [ ! -d "../$parentdir/$typedir" ]
+ if [ ! -d "../$classdir/$typedir" ]
then
- mkdir "../$parentdir/$typedir"
+ mkdir "../$classdir/$typedir"
fi
- mv -i $i ../$parentdir/$typedir/
+ mv -i $i ../$classdir/$typedir/
fi
+
+## reset variables
typedir=""
- parentdir=""
+ classdir=""
done
From 4f0c925bb09a855195c305a2b946f522449efdd6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:43:24 +0100
Subject: [PATCH 07/11] Update classifier.sh
long lines format
---
classifier.sh | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index 26af9c28..5f59f6a3 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -9,7 +9,12 @@
for i in `find . -type f`; do
classdir=`file $i | awk '{gsub("/" , "-"); gsub("," , ""); print $2}'`;
- typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); if($6) print $2,$3,$4,$5,$6; else if($5) print $2,$3,$4,$5; else if($4) print $2,$3,$4; else if($3) print $2,$3; else print $2}'`;
+ typedir=`file $i | awk 'BEGIN {OFS="-";} {gsub("/" , "-"); gsub("," , ""); \
+ if($6) print $2,$3,$4,$5,$6; \
+ else if($5) print $2,$3,$4,$5; \
+ else if($4) print $2,$3,$4; \
+ else if($3) print $2,$3; \
+ else print $2}'`;
## It the dir does not exist, create it in ../
if [ ! -d "../$classdir" ]
From dd8cc99e417245282b2c8710c2950598ab0fcb18 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:55:46 +0100
Subject: [PATCH 08/11] Update classifier.sh
---
classifier.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index 5f59f6a3..408b14ca 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -24,7 +24,7 @@ for i in `find . -type f`; do
## If the names of dir class (parent) and type (subdir) are the same, do not create subdirs
## and move files directly to the directory class
- if [ "$typedir" == "$classdir"]
+ if [ "$typedir" == "$classdir" ]
then
mv -i $i ../$classdir/
fi
From 3193fa76922544d9468f50e2ecb42501215f098f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 14:58:48 +0100
Subject: [PATCH 09/11] Update classifier.sh
fixed typo in name of variable
---
classifier.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index 408b14ca..a10f3866 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -19,7 +19,7 @@ for i in `find . -type f`; do
## It the dir does not exist, create it in ../
if [ ! -d "../$classdir" ]
then
- mkdir "../$classtdir"
+ mkdir "../$classdir"
fi
## If the names of dir class (parent) and type (subdir) are the same, do not create subdirs
From 8c65bab3acea40b28aca79d2e77445e3c1d3198d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 16:14:03 +0100
Subject: [PATCH 10/11] Update classifier.sh
duplicated word
---
classifier.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index a10f3866..f26af80c 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -28,7 +28,7 @@ for i in `find . -type f`; do
then
mv -i $i ../$classdir/
fi
-## Create subdirs and and move all archives of its appropriate class and type.
+## Create subdirs and move all archives of its appropriate class and type.
if [[ $typedir == "$classdir"* ]]
then
if [ ! -d "../$classdir/$typedir" ]
From fef4e5c43939b82b696108654ef7091589980c60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Vald=C3=A9s?=
Date: Sat, 4 Feb 2017 16:15:35 +0100
Subject: [PATCH 11/11] Update classifier.sh
---
classifier.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/classifier.sh b/classifier.sh
index f26af80c..865396c0 100644
--- a/classifier.sh
+++ b/classifier.sh
@@ -1,5 +1,5 @@
## pvaldes 2017-01-27
-## This script examine the content of each file recovered by photorec and will put it in a directory
+## This script examines the content of each file recovered by photorec and will move it into a directory
## with other files of the same type, making much easier to find what we are looking for.
## i.e. All Phyton scripts in recup_dirXXX will be automatically moved to subdirectories in a new dir named Python/,