desktop cleaning

Nils Kassube kassube at gmx.net
Thu Nov 15 14:51:41 UTC 2007


Miano, Steven M. wrote:
> > -----Original Message-----
> > From: ubuntu-users-bounces at lists.ubuntu.com [mailto:ubuntu-users-
> > bounces at lists.ubuntu.com] On Behalf Of Nils Kassube
> > Sent: Thursday, November 15, 2007 6:05 AM
> > To: ubuntu-users at lists.ubuntu.com
> > Subject: Re: desktop cleaning
> >
> > Shali 9846303531 wrote:
> > > but where do i put my files name that r not
> > > to be deleted
> >
> > OK, you want to preserve a set of files. In the script below you
> > should replace the string <directory> with the directory name you
> > want to clean. And you should replace the <space separated list of
> > files> with the list of files you want to preserve - but don't delete
> > the $dir at the end of the line.
> >
> > #!/bin/sh
> > cd <directory>
> > dir=$(mktemp -d -p /tmp)
> > mv <space separated list of files> $dir
> > rm -r ./*
> > mv $dir/* .
> > rmdir $dir
>
> Nice script Nils, 

Thanks.

Actually, now that I see it again, I see some problems :)

- The <directory> should be an absolute path.
- If the files to preserve have space characters in the filenames
  they should be quoted.
- If there are hidden files in the directory, they will not be deleted.
- If there are hidden files to be preserved, they will not be moved back.

If hidden files really are a problem, let me know it.

> that's actually exactly what I was thinking - so far 
> as it may be easier for the original poster to note or let us know what
> the keep files are, and either copying them out of the desktop dir, or
> copying them from their original location; after removing all other
> files/icons from the desktop directory.

Good point - copying the files from an original location might be the safe 
route. If arbitrary persons are allowed to change the contents of the 
desktop directory, there may be files deleted or renamed and the script 
doesn't know about it.


Nils




More information about the ubuntu-users mailing list