Automation Script Contest: 3 Free Salamander Licenses

This is a place for users to discuss Altap Salamander. Please feel free to ask, answer questions, and express your opinion. Please do not post problems, bug reports or feature requests here.
Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Automation Script Contest: 3 Free Salamander Licenses

Post by Jan Rysavy » 17 Feb 2010, 14:08

Have you already noticed Manison's Automation plugin for Altap Salamander?
We are excited to announce that Automation plugin is now included in Altap Salamander distribution.

Now you have a chance win free lifetime license of Altap Salamander including all plugins!
We are just launching a contest.

How to join
To enter the contest, simply download and install latest Altap Salamander 2.53 beta 1, and write some useful script within the Automation plugin. Publish it on this forum and let Altap Salamander users to decide by voting. Win free lifetime license for you or for your friend (if you already have one).

Rules
  • Time frame: from 2/17/2010 to 3/31/2010 for creating scripts, 4/1/2010 to 4/15/2010 for voting
  • Altap Salamander users choose the winners
  • Winners will be announced on 4/16/2010
  • Scripts must be implemented in JScript (.js) or VBScript (.vbs) and use Automation plugin interface, see Automation help for API documentation and plugins\automation\scripts directory for sample scripts
  • Scripts must be released with MIT license, see our Convert Images.js or Unpack Multiple Archives.js samples
  • Multiple versions of the script could be published and discussed here
  • One participant can publish more scripts but can win only one license (when first two scripts will be from the same author, also authors of the third and fourth script will win)
  • Altap employees cannot participate in this contest but can vote
  • Feel free to ask if you have any questions or problems with Automation plugin
Good luck to everyone and have fun :)

Post updates
02/17/2010: Initial post.
03/05/2010: Altap Salamander 2.53 beta 1 is linked instead of Preview Build (EAP) version.

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by Jan Rysavy » 18 Feb 2010, 01:04


kbirger
Posts: 11
Joined: 08 Mar 2010, 15:47

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by kbirger » 08 Mar 2010, 15:52

Hi. Do you mean for us to post the scripts we submit in this thread, or just anywhere in the General Discussion board? (I just don't see any other submissions)

Also, is it limited to one script submitted per user?

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by Jan Rysavy » 08 Mar 2010, 16:07

Hi, feel free to use this thread. You would be probably the first submitter ;-)

Please include a brief description of the script and how should we use it.

One user can submit multiple scripts, but can win only one AS license in case when more of these scripts will be rated in first three positions. In such case submitter on position 4. (and 5.) will also win.

JohnFredC
Posts: 162
Joined: 10 Dec 2005, 15:44

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by JohnFredC » 08 Mar 2010, 18:25

Hi Jan...

I have a script to post but don't care about the disclaimer part. Is it OK to post a script (as text embedded in a forum posting) without including all that legalese in the comments?

The script is just a "demo" or example and has no pretensions to be anything important or competitive.
Mouse-centric, Registered

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by Jan Rysavy » 08 Mar 2010, 18:35

Hi John, it's not a problem. The idea behind this contest was to let Altap Salamander users know about new Automation plugin, get some feedback and ideas, and have a fun :)

All scripts, ideas, bug reports, questions, or other feedback are welcome!

User avatar
otrov
Posts: 110
Joined: 10 Feb 2010, 04:39

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by otrov » 16 Mar 2010, 09:12

I made simple script which outputs some data to .csv file. Then calling:

Code: Select all

Salamander.ViewFile(csv_file)
opens internal viewer instead associated database viewer. Why?

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by Jan Rysavy » 16 Mar 2010, 09:47

otrov wrote:Salamander.ViewFile(csv_file) opens internal viewer instead associated database viewer. Why?
There is a bug in Automation plugin documentation. Currently only internal Salamander text/bin viewer could be opened from Automation.

User avatar
th.
Posts: 116
Joined: 04 Sep 2006, 23:09
Location: Germany

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by th. » 26 Mar 2010, 00:03

Based on an idea over there: http://forum.altap.cz/viewtopic.php?f=3&t=1558&start=0
Modified to remove the regional settings dependency (thanks to KNUT) + cleanup + better script name

Code: Select all

' append date.vbs
' Append the current date to the name of the focused/selected files and directories
' 29.03.2010 th.
'
Dim Fso, Item, OverwriteAnswer, YMD, NewSuffix

Set Fso = CreateObject("Scripting.FileSystemObject")
YMD = ( Year(Date)*100 + Month(Date) )*100 + Day(Date)
' The string that will be added to the old filename:    "_2010-03-29"
NewSuffix = "_" & mid(YMD, 1, 4) & "-" & mid(YMD, 5, 2) & "-" & mid(YMD, 7, 2)
OverwriteAnswer = 0

'--- Identify the item(s) to rename
If Salamander.SourcePanel.SelectedItems.Count = 0 Then ' nothing selected
   If Salamander.SourcePanel.FocusedItem.Name <> ".." then
      RenameItem Salamander.SourcePanel.FocusedItem, False
   Else
      Salamander.MsgBox "Please select or focus an item first.",0,"Rename2date"
      Salamander.AbortScript()
   End If
Else ' something is selected
   '--- Set up progress dialog
   Salamander.ProgressDialog.Style = 1
   Salamander.ProgressDialog.Maximum = Salamander.SourcePanel.SelectedItems.Count
   Salamander.ProgressDialog.Show
   Salamander.ProgressDialog.AddText "Renaming ..."
   ' Iterate through the selected items collection, rename each item
   For Each Item In Salamander.SourcePanel.SelectedItems
      RenameItem Item, True
      If Salamander.ProgressDialog.IsCancelled then Salamander.AbortScript() ' Cancelled
   Next
End If

Sub RenameItem(Item, ShowProgress)
  Dim Overwrite, IsDirectory, OldFilename, OldName, OldExtension, NewFilename
  IsDirectory = (Item.Attributes And 16) <> 0
  OldFilename = Salamander.GetFullPath(Item.Name, Salamander.SourcePanel)
  SplitFilenameAndExtension Item.Name, OldName, OldExtension
  ' Build the new name for the item
  NewFilename = Salamander.GetFullPath(OldName & NewSuffix, Salamander.SourcePanel)
  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
    'if neither "skip all" nor "all" has been pressed before, ask
    If OverwriteAnswer < 17 then _
      OverwriteAnswer = Salamander.OverwriteDialog(Fso.GetFile(NewFilename), Fso.GetFile(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 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
Last edited by th. on 31 Mar 2010, 22:47, edited 8 times in total.

User avatar
th.
Posts: 116
Joined: 04 Sep 2006, 23:09
Location: Germany

Documentation error

Post by th. » 26 Mar 2010, 00:09

There seems to be an error in the documentation of the OverwriteDialog Method.
The dialog is asking "Overwrite file1 with file2?"

Jan Rysavy
ALTAP Staff
ALTAP Staff
Posts: 5196
Joined: 08 Dec 2005, 06:34
Location: Novy Bor, Czech Republic
Contact:

Re: Documentation error

Post by Jan Rysavy » 26 Mar 2010, 10:03

th. wrote:There seems to be an error in the documentation of the OverwriteDialog Method.
The dialog is asking "Overwrite file1 with file2?"
Fixed. Thank you :)

User avatar
Georgd
Posts: 98
Joined: 24 Jul 2006, 17:13

Re: rename2date.vbs

Post by Georgd » 26 Mar 2010, 16:43

th. wrote:Based on an idea over there: http://forum.altap.cz/viewtopic.php?f=3&t=1558&start=0

Code: Select all

' rename2date.vbs
....
it crashes whole Salamander 2.53b1 on fresh Win7 64bit here :( Bug report comes via PM.
Using Salamander since v 1.52

User avatar
KNUT
Posts: 286
Joined: 12 Dec 2005, 09:57
Location: Hamburg, Germany

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by KNUT » 26 Mar 2010, 16:43

Does not work properly here: Test_010-3.-26.txt :-(

My workaround:

Code: Select all

...
YMD = ( Year(Date)*100 + Month(Date) )*100 + Day(Date)
NewFilename = Salamander.SourcePanel.Path & "\" & _
OldName & "_" & mid(YMD,1,4) & "-" & mid(YMD,5,2) & "-" & mid(YMD,7,2)
...
:)
Kind regards, KNUT
_____________________________________________
Satisfied Servant Salamander User from Version 1.5 till now

User avatar
Georgd
Posts: 98
Joined: 24 Jul 2006, 17:13

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by Georgd » 26 Mar 2010, 16:59

KNUT wrote:My workaround:
Crashes Salamander, too
Using Salamander since v 1.52

User avatar
KNUT
Posts: 286
Joined: 12 Dec 2005, 09:57
Location: Hamburg, Germany

Re: Automation Script Contest: 3 Free Salamander Licenses

Post by KNUT » 26 Mar 2010, 18:13

Georgd wrote:
KNUT wrote:My workaround:
Crashes Salamander, too
No crash! Works fine here:

Code: Select all

    ' rename2date.vbs
    ' Rename the current/selected files and directories by adding the current 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
             SplitFilenameAndExtension Item.Name, OldName, OldExtension
             ' Build the new name for the item - this has to be adapted!
             YMD = ( Year(Date)*100 + Month(Date) )*100 + Day(Date)
             NewFilename = Salamander.SourcePanel.Path & "\" & _
            OldName & "_" & mid(YMD,1,4) & "-" & mid(YMD,5,2) & "-" & mid(YMD,7,2)
            ' OldName & "_" & mid(date,7,4) & "-" & mid(date,4,2) & "-" & mid(date,1,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
Kind regards, KNUT
_____________________________________________
Satisfied Servant Salamander User from Version 1.5 till now

Post Reply