Page 3 of 4

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 08 Apr 2010, 13:50
by murphy
Jan Rysavy wrote:All registration keys are out. Please contact me if you didn't receive it (check also your spam folder).
I got mine. Thanks Thanks Thanks. Very cool. :D

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 08 Apr 2010, 13:51
by KNUT
Jan Rysavy wrote:All registration keys are out. Please contact me if you didn't receive it (check also your spam folder).
:D Thanks!! :P

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 08 Apr 2010, 15:36
by th.
Thanks a lot! 8)

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 14 Apr 2010, 19:54
by p4ul
I got mine too. Thanks Jan!

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 24 Aug 2010, 13:42
by Syl
These scripts are really great :)
Is it planned to have a database on the official website ?

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 24 Aug 2010, 13:47
by Jan Rysavy
It would be nice, but we would need maintainer.

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 26 Aug 2010, 13:57
by KNUT
Jan Rysavy wrote:It would be nice, but we would need maintainer.
What's about a simple Wiki? :?

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 26 Aug 2010, 14:19
by Jan Rysavy
Such list could be maintained on this forum, there is option to edit own posts. See for example this post: http://forum.altap.cz/viewtopic.php?f=23&t=3959#p19820

Wiki could be next step.

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 30 Aug 2010, 07:36
by Jan Rysavy
New script idea: Recursive File/Directory list.
Could be based on existing C:\Program Files (x86)\Altap Salamander\plugins\automation\scripts\Count Lines.js (for example).

NEW SCRIPT: rename2filedate.vbs

Posted: 30 Aug 2010, 17:44
by KNUT
Append the filedate (NOT the current date!) to the selected file.

Code: Select all

    ' rename2date.vbs
    ' Rename the current/selected files and directories by adding the date
    ' 25.03.2010 th.
    '
    Dim Items
    Dim Fso, Item, OverwriteAnswer, Overwrite

    Set Fso = CreateObject("Scripting.FileSystemObject")

    OverwriteAnswer = 0

    '--- Identify the item(s) to rename
    If Salamander.SourcePanel.SelectedItems.Count = 0 Then
       If Salamander.SourcePanel.FocusedItem.Name <> ".." then
          RenameItem Salamander.SourcePanel.FocusedItem, False
       Else
          Salamander.MsgBox "Please select or focus an item first.",0,"Rename"
          Salamander.AbortScript()
       End If
    Else
       Set Items = Salamander.SourcePanel.SelectedItems
    End If

    If VarType(Items) <> 0 Then ' vbEmpty
       '--- Set up progress dialog
       Salamander.ProgressDialog.Style = 1
       Salamander.ProgressDialog.Maximum = Items.Count
       Salamander.ProgressDialog.Show
       Salamander.ProgressDialog.AddText "Renaming ..."
       ' Iterate through the item collection rename each item
       For Each Item In Items
          RenameItem Item, True
          If Salamander.ProgressDialog.IsCancelled then Salamander.AbortScript() ' Canceled
       Next
    End If

    Sub RenameItem(Item, ShowProgress)
          If Item.Name <> ".." Then
             IsDirectory = (Item.Attributes And 16) <> 0
             OldFilename = Salamander.SourcePanel.Path & "\" & Item.Name
             'Salamander.MsgBox Item.DateLastModified
             SplitFilenameAndExtension Item.Name, OldName, OldExtension
             ' Build the new name for the item - this has to be adapted!
             YMD = Item.DateLastModified
             YMD1 = InStr (1, YMD, ".")
             YMD2 = InStr (YMD1+1, YMD, ".")
             YMDMON = "0" & mid(YMD,YMD1+1,YMD2-YMD1-1)
             YMDDAY = "0" & mid(YMD,1,YMD1-1)
             'Salamander.MsgBox YMD & "#" & YMD1 & "#" & YMD2 & "#" & YMDDAY & "#" & YMDMON
             NewFilename = Salamander.SourcePanel.Path & "\" & _
             OldName & "_" & mid(YMD,YMD2+1,4) & "-" & Right(YMDMON,2) & "-" & Right(YMDDAY,2)
             If OldExtension <> "" Then NewFilename = NewFilename & "." & OldExtension
             If ShowProgress Then
                Salamander.ProgressDialog.Step(1)
                Salamander.ProgressDialog.AddText vbCrLf & OldFilename & " --> " & NewFilename
             End If
             Overwrite = True
             If Fso.FileExists(NewFilename) Then
                'neither "skip all" nor "all" has been pressed before, ask
                If OverwriteAnswer < 17 then _
                   OverwriteAnswer = Salamander.OverwriteDialog(NewFilename, OldFilename, 4)
                Select Case OverwriteAnswer
                   Case 2
                      Salamander.AbortScript() ' Cancel
                   Case 7, 16, 17
                      Overwrite = False
                   Case Else ' Overwrite, target has to be deleted
                      If IsDirectory then
                         Fso.DeleteFolder NewFilename
                      Else
                         Fso.DeleteFile NewFilename
                      End If
                End Select
             End If
             If Overwrite then
                If IsDirectory Then
                   Fso.MoveFolder OldFilename, NewFilename
                Else
                   Fso.MoveFile OldFilename, NewFilename
                End If
             End If
          End If
    End Sub

    Sub SplitFilenameAndExtension(FileName, Name, Extension)
          Dim n
          
          For n = Len(FileName) to 1 step -1
                If Mid(FileName, n, 1) = "." Then Exit For
          Next
          if n < 1 then
             Name = FileName
             Extension = ""
          Else
             Name = Left(FileName, n - 1)
             Extension = Mid(FileName, n + 1)
          End If
    End Sub

NEW SCRIPT: renameorcopy2filedate.vbs

Posted: 31 Aug 2010, 10:48
by KNUT
Another dirty 8) hack: rename OR copy 2 filedate...

Code: Select all

    ' rename2date.vbs
    ' Rename the current/selected files and directories by adding the date
    ' 25.03.2010 th.
    ' 31.08.2010 KNUT
    Dim Items
    Dim Fso, Item, OverwriteAnswer, Overwrite

    Set Fso = CreateObject("Scripting.FileSystemObject")

    OverwriteAnswer = 0

    'Copy or rename
    Set Form1 = Salamander.Forms.Form("Only Rename or Copy to an new file?")
    Form1.b1 = Salamander.Forms.Button("&Copy", 3)
    Form1.b2 = Salamander.Forms.Button("&Rename", 4)
    Result = Form1.Execute
    Select Case Result
    Case 3
        DOCOPY = True
    Case 4
        DOCOPY = False
    End Select
    If Path <> "" Then DOCOPY = False

    '--- Identify the item(s) to rename
    If Salamander.SourcePanel.SelectedItems.Count = 0 Then
       If Salamander.SourcePanel.FocusedItem.Name <> ".." then
          RenameItem Salamander.SourcePanel.FocusedItem, False
       Else
          Salamander.MsgBox "Please select or focus an item first.",0,"Rename"
          Salamander.AbortScript()
       End If
    Else
       Set Items = Salamander.SourcePanel.SelectedItems
    End If

    If VarType(Items) <> 0 Then ' vbEmpty
       '--- Set up progress dialog
       Salamander.ProgressDialog.Style = 1
       Salamander.ProgressDialog.Maximum = Items.Count
       Salamander.ProgressDialog.Show
       Salamander.ProgressDialog.AddText "Renaming ..."
       ' Iterate through the item collection rename each item
       For Each Item In Items
          RenameItem Item, True
          If Salamander.ProgressDialog.IsCancelled then Salamander.AbortScript() ' Canceled
       Next
    End If

    Sub RenameItem(Item, ShowProgress)
          If Item.Name <> ".." Then
             IsDirectory = (Item.Attributes And 16) <> 0
             OldFilename = Salamander.SourcePanel.Path & "\" & Item.Name
             'Salamander.MsgBox Item.DateLastModified
             SplitFilenameAndExtension Item.Name, OldName, OldExtension
             ' Build the new name for the item - this has to be adapted!
             YMD = Item.DateLastModified
             YMD1 = InStr (1, YMD, ".")
             YMD2 = InStr (YMD1+1, YMD, ".")
             YMDMON = "0" & mid(YMD,YMD1+1,YMD2-YMD1-1)
             YMDDAY = "0" & mid(YMD,1,YMD1-1)
             'Salamander.MsgBox YMD & "#" & YMD1 & "#" & YMD2 & "#" & YMDDAY & "#" & YMDMON
             NewFilename = Salamander.SourcePanel.Path & "\" & _
             OldName & "_" & mid(YMD,YMD2+1,4) & "-" & Right(YMDMON,2) & "-" & Right(YMDDAY,2)
             If OldExtension <> "" Then NewFilename = NewFilename & "." & OldExtension
             If ShowProgress Then
                Salamander.ProgressDialog.Step(1)
                Salamander.ProgressDialog.AddText vbCrLf & OldFilename & " --> " & NewFilename
             End If
             Overwrite = True
             If Fso.FileExists(NewFilename) Then
                'neither "skip all" nor "all" has been pressed before, ask
                If OverwriteAnswer < 17 then _
                   OverwriteAnswer = Salamander.OverwriteDialog(NewFilename, OldFilename, 4)
                Select Case OverwriteAnswer
                   Case 2
                      Salamander.AbortScript() ' Cancel
                   Case 7, 16, 17
                      Overwrite = False
                   Case Else ' Overwrite, target has to be deleted
                      If IsDirectory then
                         Fso.DeleteFolder NewFilename
                      Else
                         Fso.DeleteFile NewFilename
                      End If
                End Select
             End If
             
             If Overwrite then
              If DOCOPY then
                If IsDirectory Then
                   Fso.CopyFolder OldFilename, NewFilename
                Else
                   Fso.CopyFile OldFilename, NewFilename
                End If
              Else
                If IsDirectory Then
                   Fso.MoveFolder OldFilename, NewFilename
                Else
                   Fso.MoveFile OldFilename, NewFilename
                End If
              End If
             End If
          End If
    End Sub

    Sub SplitFilenameAndExtension(FileName, Name, Extension)
          Dim n
          
          For n = Len(FileName) to 1 step -1
                If Mid(FileName, n, 1) = "." Then Exit For
          Next
          if n < 1 then
             Name = FileName
             Extension = ""
          Else
             Name = Left(FileName, n - 1)
             Extension = Mid(FileName, n + 1)
          End If
    End Sub

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 26 Feb 2011, 11:59
by fraktik
Ahoj soutěžci (hezký tvar, ne? ;-) ), velké díky tvůrcům AS (aneb něco chci a tak začínám podkuřovat :wink: ):

Už dlouho jsem se chystal zprovoznit "Image Resize script" dle vlákna Convert Images automation plugin, zkusil jsem ho pustit ale hned cosi zařval (dohledáno třeba zde: PB44: Automation plugin a externi program), tak jsem si tedy stáhl a nainstaloval utilitku [url=http://image_magick.veidrodis.com/image_magick/windows/ImageMagick-windows.zip]ImageMagic[/url] (nechápu proč nemají na stránkách přímé odkazy na instalátor a člověk se musí brodit celým jejich mirrorem).
Ještě před ruční editací skriptu C:\Program Files\Altap Salamander 2.53\plugins\automation\scripts\Convert Images.js jsem si ho zkusil pustit jen tak - a byl velice příjemně překvapen, že se umí sám zeptat na cestu k prográmku).

Ovšem tím příjemná překvapení skončila:
Je zde zřejmě sice možnost nějakého rekurznivního vnoření se do adresářové struktury, ale GUI nenabízí prakticky žádné možnosti + upravená fotka přišla o Exif info (zjištěno jen náhodou (Landscape místo Portrét zobrazení náhledu)) - i přestože dle BUG: convert 6.5 -resize looses EXIF tag XResolution by to už přes rok mělo být vyřešeno (stáhnul jsem nejnovější versi z 2011-02-13, tj. 6.6.7-7).
Navíc pokud pustím na totožný obrázek Irfan View, ušetřím (při nastavení 50% kvality - tento posuvník (či číselná hodnota) by byl pro skript mým ideálem) 88% místa. I samotný PictView to zvládá (automaticky a bez zřejmé možnosti nastavení) na 75% původní velikosti (tj. ale dvojnásobná oproti Irfanu), zatímco tento skript vygeneruje jen soubor poloviční velikosti oproti původnímu... :-/\
Když jsem ho snižováním "-quality" parametru (až na pouhých 25) donutil dojít na stejnou velikost souboru, vykazoval daleko větší "zubatost" + se navíc snížilo i celkové rozlišení...

Velice příjemná by byla i možnost zachování původního data ve vlastnostech obrázků.

Našla by se tedy (prosím prosím) dobrá duše, která by mi poradila jak změnit onen řádek:

Code: Select all

var imageMagickParams = "-resample 100x100 -quality 80";
dle mých představ? :roll:

Edit:
Ether tu několíkráte zmiňoval (nesrovnatelně menší) utilitku NConvert - uměl by ji případně někdo někdo "zasekat" do "ImageResizeScriptu"?

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 16 Jun 2011, 19:10
by otrov
Python Automation Script: "Imgur Upload.pys"

Tested on Python 2.6.6. Should work with later Python version also. Python 2.5 would need "json" module IIRC
Uses Standard Python Library, although http://sourceforge.net/projects/pywin32/ is needed for COM magic to work (or Active Python distribution)

OK. Those were boring facts which shouldn't make a difference in most cases.

Script itself: http://pastebin.com/BhLaVpX4
Download: http://pastebin.com/download.php?i=BhLaVpX4

When evoked it would try to upload current focused file, then provide various links

In action:

Image

Image

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 16 Jun 2011, 20:15
by otrov
Have a question also :)

Does Salamander COM object exist to be called with Dispatch i.e.?
I tried "win32com.client.Dispatch('Salamander.Application')", but nothing
I browser available ProgIDs but couldn't find anything related to Altap or Salamander or Automation

Re: Automation Script Contest: 3 Free Salamander Licenses

Posted: 19 Jun 2011, 12:05
by manison
otrov wrote:Does Salamander COM object exist to be called with Dispatch i.e.?
I tried "win32com.client.Dispatch('Salamander.Application')", but nothing
I browser available ProgIDs but couldn't find anything related to Altap or Salamander or Automation
The Salamander object is not available outside the Automation script, it's only accessible through the Salamander global variable. You cannot instantiate it using Dispatch or any other mechanism the language provides. What are you trying to do?