This is a discussion on Automate deletion of files within the Debian Linux support forums, part of the Debian Linux category; --> Hi all, Although I am not a newbie to Linux, I am to Linux scripting. All my scripting skills ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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! |
| |||
| 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 |
| |||
| 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 |
| |||
| 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. |
| |||
| > > #!/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! |
| ||||
| Dave Kelly wrote: > 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 > > 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 |