Linux Debian support - Automate deletion of files

This is Interesting: Free IT Magazines  
Home > Archive > Linux Debian support > September 2006 > Automate deletion of files





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Automate deletion of files
Hugh Janus

2006-01-04, 5:52 pm

Hi all,

Although I am not a newbie to Linux, I am to Linux scripting. All my
scripting skills are with Windows so they don't apply! Anyway, I am
running a Debian server as part of a programming project and I have a
requirement for a script that hopefully someone can help me with!

Under the /home path I have several user folders. What I would like to
have is a script that deletes the entire contents of specific folders
on a regular basis. The criteria for files to be deleted with have a
prefix on the filename like "DEL-" or something similar. The criteria
for which folders to scan will be whatever paths I list in a text file
somewhere on the server.

Any help would be greatly appreciated! As I said, I have no Linux
scripting experience whatsoever so I am hoping that someone will have a
similar script that they could post and help me modify.

Thanks a million in advance!

Dave Kelly

2006-01-04, 5:52 pm

Hugh Janus wrote:
> Hi all,
>
> Although I am not a newbie to Linux, I am to Linux scripting. All my
> scripting skills are with Windows so they don't apply! Anyway, I am
> running a Debian server as part of a programming project and I have a
> requirement for a script that hopefully someone can help me with!
>
> Under the /home path I have several user folders. What I would like to
> have is a script that deletes the entire contents of specific folders
> on a regular basis. The criteria for files to be deleted with have a
> prefix on the filename like "DEL-" or something similar. The criteria
> for which folders to scan will be whatever paths I list in a text file
> somewhere on the server.
>
> Any help would be greatly appreciated! As I said, I have no Linux
> scripting experience whatsoever so I am hoping that someone will have a
> similar script that they could post and help me modify.
>
> Thanks a million in advance!
>



#!/bin/bash

for i in *jpg; do echo $i; convert -size 320x240 $i -resize 320x240 $i; done

A short script like this could do the job. Where it is looking for
files with the '*.jpg' extension, you could change that to look for the
'DEL*' prefix.

Where this used 'convert' to resize the images, read the manual on 'rm'
for the flags you will need to force removal without human responce.

And then ask questions here again.

dave
Dan N

2006-01-04, 8:46 pm

On Wed, 04 Jan 2006 12:53:05 -0800, Hugh Janus wrote:

> What I would like to
> have is a script that deletes the entire contents of specific folders on a
> regular basis.


Use the script that was suggested and run it as a cron task (man cron).

Dan


Michael C.

2006-01-05, 2:46 am

On 4 Jan 2006 12:53:05 -0800,
Hugh Janus <my-junk-account@hotmail.com> wrote:
>
>
> Hi all,
>
> Although I am not a newbie to Linux, I am to Linux scripting. All my
> scripting skills are with Windows so they don't apply! Anyway, I am
> running a Debian server as part of a programming project and I have a
> requirement for a script that hopefully someone can help me with!
>
> Under the /home path I have several user folders. What I would like to
> have is a script that deletes the entire contents of specific folders
> on a regular basis. The criteria for files to be deleted with have a
> prefix on the filename like "DEL-" or something similar. The criteria
> for which folders to scan will be whatever paths I list in a text file
> somewhere on the server.
>
> Any help would be greatly appreciated! As I said, I have no Linux
> scripting experience whatsoever so I am hoping that someone will have a
> similar script that they could post and help me modify.
>
> Thanks a million in advance!
>


#!/bin/sh

for directory in `cat directory-list` ;
do
echo rm /home/mike/${directory}/DEL-* ;
done ;

Remove echo, and substitute your own home as needed.

Michael C.
--
mcsuper5@usol.com http://mcsuper5.freeshell.org/

If we work together we share together.
Hugh Janus

2006-01-05, 2:46 am


>
> #!/bin/sh
>
> for directory in `cat directory-list` ;
> do
> echo rm /home/mike/${directory}/DEL-* ;
> done ;
>
> Remove echo, and substitute your own home as needed.
>
> Michael C.
> --
> mcsuper5@usol.com http://mcsuper5.freeshell.org/
>
> If we work together we share together.



Wow! Thanks everyone for the help! I'll get on it and hopefully have
something working in the next couple of days!

the enemies of god

2006-09-10, 1:12 pm

Dave Kelly wrote:
> Hugh Janus wrote:
>
>
>
> #!/bin/bash
>
> for i in *jpg; do echo $i; convert -size 320x240 $i -resize 320x240 $i; done
>
>

this is why linux sucks

--

unmade in the distance

unmade in her watery eyes
clouds under the stars, fenceposts
words turned into signs

clouds of the revolution

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com