hard cleaning
am 24.11.2007 11:06:56 von franzi
I need to clean all my documents and files under macosx,of about 40gb
I'd know how can i in one or more lines,find files that are about my
documents about medicine,and those files where inside is written
[ipotensione,arteria,infermieristica,bls,etc,all ineherent to
medicine.].than creat a directory where put all those files,and
removes those finded,in 2 distinct partitions and volumes
Thanks in advanced
Re: hard cleaning
am 24.11.2007 18:41:09 von Glenn Jackman
At 2007-11-24 05:06AM, "franzi" wrote:
> I need to clean all my documents and files under macosx,of about 40gb
> I'd know how can i in one or more lines,find files that are about my
> documents about medicine,and those files where inside is written
> [ipotensione,arteria,infermieristica,bls,etc,all ineherent to
> medicine.].than creat a directory where put all those files,and
> removes those finded,in 2 distinct partitions and volumes
Your solution will involve:
find dirname -type f
strings (if your files are not just text)
grep or awk or sed
You are going to have to be explicit in the list of words or phrases you
expect to find in your files. You can't simply tell your computer to
"look for medical terms".
I'd do something like (untested, assuming bash):
function check_medical () {
local destination_dir="$2"
local filename="$1"
local awk_script='
/ipotensione|arteria|infermieristica|etc/ {exit 0}
END {exit 1}
'
if awk "$awk_script" "$filename"
then
mv "$filename" "$destination_dir"
fi
}
new_dir="My Medical Files"
mkdir "$new_dir"
find "My Documents" -type f -print0 | xargs -0 check_medical "$new_dir"
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
Re: hard cleaning
am 24.11.2007 19:27:29 von franzi
On 24 Nov, 18:41, Glenn Jackman wrote:
> At 2007-11-24 05:06AM, "franzi" wrote:
>
> > I need to clean all my documents and files under macosx,of about 40gb
> > I'd know how can i in one or more lines,find files that are about my
> > documents about medicine,and those files where inside is written
> > [ipotensione,arteria,infermieristica,bls,etc,all ineherent to
> > medicine.].than creat a directory where put all those files,and
> > removes those finded,in 2 distinct partitions and volumes
>
> Your solution will involve:
> find dirname -type f
> strings (if your files are not just text)
> grep or awk or sed
>
> You are going to have to be explicit in the list of words or phrases you
> expect to find in your files. You can't simply tell your computer to
> "look for medical terms".
>
> I'd do something like (untested, assuming bash):
>
> function check_medical () {
> local destination_dir="$2"
> local filename="$1"
> local awk_script='
> /ipotensione|arteria|infermieristica|etc/ {exit 0}
> END {exit 1}
> '
> if awk "$awk_script" "$filename"
> then
> mv "$filename" "$destination_dir"
> fi
> }
>
> new_dir="My Medical Files"
> mkdir "$new_dir"
> find "My Documents" -type f -print0 | xargs -0 check_medical "$new_dir"
>
> --
> Glenn Jackman
> "You can only be young once. But you can always be immature." -- Dave Barry
thanks very much i will try it as soon as possible