[Gambas-user] cleaning gambas.1000 dir

Bruce Steers bsteers4 at gmail.com
Mon Nov 20 14:21:19 CET 2023


On Mon, 20 Nov 2023 at 08:11, BB <adamnt42 at gmail.com> wrote:

> On 20/11/23 10:05 am, Jussi Lahtinen wrote:
> > I think you are correct, but why bother?
> >
> > Jussi
> >
> Good point, but /tmp has always ended up with gazillions of empty
> /tmp/gambas1000/nnnnnnnnn directories that I would like to self-imolate
> once a day at least or at best if they are empty. It would make
> observations of "live" files temporary files easier.
>

Yep, that's exactly why.
Sometimes working on a program i want to have a look for it's temp dir for
various reasons.
there can be hundreds of folders in there , most of which are redundant.

I removed the code from my IDE startup and added e new menu item in Tools
menu

Here's a super simple gambas-script for doing it too if anyone is
interested, it tells you how many redundant folders exist and gives option
to delete them or not...

-------------------------------
#!/usr/bin/env gbs3

Use "gb.gui"

Public Sub Main()

  Dim sDir As String = File.Dir(File.Dir(Temp()))
  Dim aObs As String[] = []

  For Each s As String In Dir(sDir, "*", gb.Directory)
    If s Match "^[0-9]+$" Then
      If Not Exist("/proc" &/ s) Then aObs.Add(s)
    Endif
  Next

  If Message.Question("Found " & aObs.Count & " obsolete dirs", "Remove",
"Leave") = 1 Then
    Shell "cd " & Shell(sDir) & "; rm -vrf " & aObs.Join(" ") Wait
  Endif

End
-------------------------------

Or scrunched into a handy single terminal line using gambas scripting...
$ gbs3 <<< $(echo -e "Use \"gb.gui\"\nPublic Sub Main()\n  Dim sDir As
String = File.Dir(File.Dir(Temp()))\n  Dim aObs As String[] = []\n  For
Each s As String In Dir(sDir, \"*\", gb.Directory)\n  Print s;;\n    If s
Match \"^[0-9]+$\" Then\n      If Not Exist(\"/proc\" &/ s) Then
aObs.Add(s)\n    Endif\n  Next\nPrint \"\"\n  If Message.Question(\"Found
\" & aObs.Count & \" obsolete dirs\", \"Remove\", \"Leave\") = 1 Then\n
 Shell \"cd \" & Shell(sDir) & \"; rm -vrf \" & aObs.Join(\" \") Wait\n
 Endif\nEnd")

Or even handier add an alias to $HOME/.bashrc
alias gbclean='gbs3 <<< $(echo -e "Use \"gb.gui\"\nPublic Sub Main()\n  Dim
sDir As String = File.Dir(File.Dir(Temp()))\n  Dim aObs As String[] = []\n
 For Each s As String In Dir(sDir, \"*\", gb.Directory)\n  Print s;;\n
 If s Match \"^[0-9]+$\" Then\n      If Not Exist(\"/proc\" &/ s) Then
aObs.Add(s)\n    Endif\n  Next\nPrint \"\"\n  If Message.Question(\"Found
\" & aObs.Count & \" obsolete dirs\", \"Remove\", \"Leave\") = 1 Then\n
 Shell \"cd \" & Shell(sDir) & \"; rm -vrf \" & aObs.Join(\" \")
Wait\n  Endif\nEnd")'

Respects
BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231120/8d99e683/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Untitled.jpg
Type: image/jpeg
Size: 148162 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20231120/8d99e683/attachment-0001.jpg>


More information about the User mailing list