FlareRenamer - program to rename files

So you have written that new, must have program. Let us see it here.
User avatar
henry15ea
Posts: 9
Joined: Friday 17th December 2021 5:23pm
Contact:

FlareRenamer - program to rename files

Post by henry15ea »

Hello good day to all, this publication is to present a program that I recently finished , its name is FlareRenamer , it is a program that will help us to work with the names of the files that we have in a directory or that we add in the program, we can apply different filters as .

* File name in Lower Case, Upper Case, Capitalize .
* Find and replace word.
* Number the files .
* Add date .
* Add a name for all files(The numbering is enabled to avoid collisions).
* Different languages available.
* File filtering by extension.

The program has the RPM and DEB packages . also an OBS repository is available for openSUSE distributions where projects will be uploaded much faster . without further ado I leave you the address of the blog I made so you know about it . many thanks, suggestions to improve the program can be made at the following address.

henry151ea@yandex.com

Image

as well in the blog or in this publication.
project link
https://sourceforge.net/projects/flarerenamer/

blog in Spanish about the program https://areadevsoft.blogspot.com/
User avatar
cogier
Site Admin
Posts: 1118
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: FlareRenamer - program to rename files

Post by cogier »

I tried your program but it crashed here: -

Image
User avatar
henry15ea
Posts: 9
Joined: Friday 17th December 2021 5:23pm
Contact:

Re: FlareRenamer - program to rename files

Post by henry15ea »

many thanks for trying the program, it would help me a lot to know what version of package I install, if it was in rpm or the version of packages .deb, the problem is due to the lack of icon libraries .

I attach the necessary libraries and the path where it should go .


/home/henryguzman/.local/share/gambas3/lib/areadev

create folder "areadev" if not exists and change "henryguzman" by your username.


this will help me to know if the problem is when copying the libraries, again I appreciate your response in the forum.
Attachments
libs.zip
unzip the libs file.zip in the following path

home/henryguzman/.local/share/gambas3/lib/areadev
(2.41 MiB) Downloaded 196 times
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: FlareRenamer - program to rename files

Post by BruceSteers »

I think you should do away with easy_icons lib and use gambas routines.

You should be able to accomplish all the easy icons lib does with gb.desktop

Desktop.GetFileIcon(sFilePath, iSize)

DesktopMime.FromFile(sFilePath).GetIcon(iSize)

Various other means

Why exactly do yo use the easy icons lib and not gambas routines?
If at first you don't succeed , try doing something differently.
BruceS
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: FlareRenamer - program to rename files

Post by BruceSteers »

Another Icon searching function for you....
(I use this class in my apps and call SearchIcons() it works for things like gambas.desktop where the icon and exe name set have no path set, just 'gambas3')

' Gambas class file

Create Static
Export


Public Sub SearchIcons(name As String, Optional PreferedTheme As String) As String

  Dim sTheme, sPrefered As String

  Shell "gsettings get org.gnome.desktop.interface icon-theme | tr -d \"'\"" Wait To sTheme
  sTheme = "/" & RTrim(sTheme)

  If PreferedTheme Then sPrefered = GetPeferedIcon("/" & PreferedTheme, name)

  If Not sPrefered Then sPrefered = GetPeferedIcon(sTheme, name)

  ' If Not sPrefered Then sPrefered = GetPeferedIcon("/hicolor", name)
  If Not sPrefered Then sPrefered = GetPeferedIcon("", name)

  Return sPrefered

End

Private Sub GetPeferedIcon(theme As String, name As String) As String

  Dim sRet, sPrefered As String = "", sList, sPth As String[], c, maxsize As Integer

  Shell "find /usr/share/icons" & theme & "/ -name '" & name & ".*'" Wait To sRet
  If sRet Then
    sList = Split(RTrim(sRet), "\n")
    If sList.Count = 1 Then Return sList[0]

    For c = 0 To sList.Max
      sPth = Split(Right(sList[c], -17), "/")
      If sPth.Count > 1 Then
        If String.Mid(sPth[1], (sPth[1].Len / 2) + 1, 1) = "x" Then
          sPth = Split(sPth[1], "x")
          If Val(sPth[0]) > maxsize Then
            maxsize = Val(sPth[0])
            sPrefered = sList[c]
          Endif
        Endif
      Endif
      If Not maxsize Then sPrefered = sList[c]
    Next

  Endif

  Return sPrefered

End
Last edited by BruceSteers on Sunday 30th January 2022 1:07am, edited 1 time in total.
If at first you don't succeed , try doing something differently.
BruceS
User avatar
henry15ea
Posts: 9
Joined: Friday 17th December 2021 5:23pm
Contact:

Re: FlareRenamer - program to rename files

Post by henry15ea »

Many thanks, I have solved the problem, since the installation file did not make the copy of the required libraries , there was also a problem of copying translation files to the destination configuration directory , I will take into account your tips .
User avatar
PJBlack
Posts: 184
Joined: Tuesday 9th June 2020 10:26pm
Location: Florstadt, Hessen, Germany

Re: FlareRenamer - program to rename files

Post by PJBlack »

Bildschirmfoto vom 2022-01-30 01-41-21.png
Bildschirmfoto vom 2022-01-30 01-41-21.png (34.36 KiB) Viewed 4412 times
second time i try ... second version that did not work ...
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: FlareRenamer - program to rename files

Post by BruceSteers »

Here is a function from one of my apps (a file browser) that lists a folder and get's icons for all items.
It checks if a file is a .desktop file and uses it's Icon= field anf if not it uses methods to get defaults.

Maybe it will help.
(Ps, the AppIcon class is the class i posted in the previous posts)
Public Sub LoadPath(Directory As String)

  $iIconSize = Me.IconSize
  If Not pDirIcon Then pDirIcon = Picture["icon:/128/directory"]

  If Directory Then $sPath = Directory Else Return ' Directory = User.Home
  $sItems = Dir(Directory).Sort(gb.Ascent + gb.IgnoreCase + gb.Natural)

  Dim sDirs As New String[]
  Dim sFiles As New String[]
  Dim  ic As Picture, df As MyDesktopFile, sVar As String, icA As New Collection

  For Each sVar In $sItems
    df = Null
    ic = Null

    If IsDir($sPath &/ sVar) Then
      ic = pDirIcon.Image.Stretch($iIconSize, $iIconSize).Picture
      sDirs.Add(sVar)
    Else
      Select LCase(File.Ext(sVar))
        Case "zip", "tar", "gz", "bzip", "rar", "ace"
          ic = Picture["icon:/" & $iIconSize & "/archive"]

        Case "desktop"
          df = New MyDesktopFile($sPath &/ sVar)
          If Not df Then Continue

          If (Not Exist(df.Icon)) Or If (Not InStr(df.Icon, "/")) Then
            Dim sIcon As String = AppIcon.SearchIcons(df.Icon, Style.Name)
            If sIcon And Exist(sIcon) Then df.Icon = sIcon
          Endif
          Try ic = Image.Load(df.Icon).Stretch($iIconSize, $iIconSize).Picture
          sFiles.Add(sVar)
        Case "png", "jpg", "bmp", "jpeg"
          Try ic = Image.Load($sPath &/ sVar).Stretch($iIconSize, $iIconSize).Picture
          sFiles.Add(sVar)

        Case Else
          Dim mt As DesktopMime
          mt = DesktopMime.FromFile($sPath &/ sVar)
          If mt.Type Like "*x-compressed*" Then
            ic = Picture["icon:/" & $iIconSize & "/archive"]
          Else
            ic = Desktop.GetFileIcon($sPath &/ sVar, $iIconSize)
          Endif
          sFiles.Add(sVar)
      End Select
    Endif

    If Not ic Then ic = Desktop.GetFileIcon($sPath &/ sVar, $iIconSize)
    If Not ic Then ic = Stock["128/file"].Image.Stretch($iIconSize, $iIconSize).Picture

  ' add the icon picture to the collection under it's file name
   icA.Add(ic, sVar)

  Next

'  create icons either naturally or dir's first

  Object.Lock($hView)
  If $bDirsFirst Then

    For Each s As String In sDirs
      mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
      mf.Visible = If(Left(s) = ".", $bShowHidden, True)
      AddToGrid(mf)
      mf.Menu = "mnuEdit"
    Next
    For Each s As String In sFiles
      mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
      mf.Visible = If(Left(s) = ".", $bShowHidden, True)
      mf.Menu = "mnuEdit"
       AddToGrid(mf)
    Next

  Else
    For Each s As String In $sItems
      mf = New MyIcon($hView, Directory &/ s, icA[s]) As "Icon"
      mf.Visible = If(Left(s) = ".", $bShowHidden, True)
      mf.Menu = "mnuEdit"
      AddToGrid(mf)
    Next
  Endif

  $hView.Refresh
  $hView.Scroll(iScroll[0], iScroll[1])
  Raise Loaded

Catch
  Debug Error.Text & gb.Lf & Error.Backtrace.Join("\n") & "'''"

End
If at first you don't succeed , try doing something differently.
BruceS
User avatar
henry15ea
Posts: 9
Joined: Friday 17th December 2021 5:23pm
Contact:

Re: FlareRenamer - program to rename files

Post by henry15ea »

i've been reviewing and trying to maintain the icon library, but as you say I'm going to remove the libraries and I'm going to check if I can load the icons with the example I put here, the versions in sourceforge remove them until all the modifications are complete . thank you for taking the time to test .
User avatar
BruceSteers
Posts: 1523
Joined: Thursday 23rd July 2020 5:20pm
Location: Isle of Wight
Contact:

Re: FlareRenamer - program to rename files

Post by BruceSteers »

henry15ea wrote: Sunday 30th January 2022 3:10am i've been reviewing and trying to maintain the icon library, but as you say I'm going to remove the libraries and I'm going to check if I can load the icons with the example I put here, the versions in sourceforge remove them until all the modifications are complete . thank you for taking the time to test .
Honestly dude forget about libraries , nothing but headaches and lots of time trying to explain to people how to install them.

Here's a present for ya..

I just made a simple app that has a FileChooser object , just click a file and it loads it's icon at the bottom.

It has a function LoadIcon(Path As String)
It's basically the code i sent before but all cleaned up

It finds the icon and loads it into PictureBox1

You can see the difference in the picturebox and the filechooser icons, FileChooser just uses Desktop.GetFileIcon() i think.

My function checks .desktop files and loads their icons and also loads image icons as previews.

for a faster app just use a set (existing) icon size like 32 and change all the
Picture["icon:/128/iconname"].Image.Stretch($iIconSize, $iIconSize).Picture
statements to just...
Picture["icon:/32/iconname"]

My application can use any icon size so it loads an existing 128px icon and shrinks it
Last edited by BruceSteers on Sunday 30th January 2022 6:56pm, edited 1 time in total.
If at first you don't succeed , try doing something differently.
BruceS
Post Reply