Topic: Scripting Siren

I don't know if i can make myself clear or how hard is this to code...

...but could Siren execute the code of an scripting language
and execute this for all the selected files and rename this file like the code says?

I think therefor Siren must provide some keywords like
@b for basename
@e for extension
@p for the path
which we can use in the code as variables.

In the code i would work with this variables
var = split(@b, " ")
...

and give my result back to Siren which display my result as the future name.


Well, don't know if this is possible or not ,.... just an idea for later use maybe.

Re: Scripting Siren

You mean: for each file, call an external program, "give" him some specific info, catch a returned string and finally rename the file with it ?

3 (edited by Stefan 2007-04-18 20:40:49)

Re: Scripting Siren

rplr wrote:

You mean:
for each file,

Yes.. but maybe not for each file discrete but as, hmm, kind of an array?
Would not be as slow as each single file alone.

rplr wrote:

call an external program,
"give" him some specific info,
catch a returned string and finally rename the file with it ?

Yes, exactly.


- Just i and my ideas :-(  -

I meant this for guys and gals who are able to wrote an script with VB or C or AutoHotkey e.t.c. pp.

Perhaps we can extend the features  of Siren with such kind of plugins?
For special purposes.
Which you don't want to include in the main app.


----
EDIT:
As addition or instead ... what about a new feature like this...

1. user select some files
2. user press new button "Edit in editor"

3. Siren export the file names to %tmp%\sirenXYZ123.txt
... and shows an "please wait" -dialog

4. Siren starts the editor the user sets in the options ...
... or the windows default... with %tmp%\sirenXYZ123.txt   as parameter.

5. Siren waits ---- till the user is finished and had saved the modified %tmp%\sirenXYZ123.txt

6. either Siren detects that the %tmp%\sirenXYZ123.txt  time stamp is altered ....
...or the user have to press an [OK]-button in the "wait" dialog

7. Siren re-reads the %tmp%\sirenXYZ123.txt  and show this line per line as future names.
7b Siren deletes %tmp%\sirenXYZ123.txt

8. over to the user....

4 (edited by Stefan 2007-06-09 03:00:07)

Re: Scripting Siren

I think i have wrote smtg like this somewhere else ... but now i didn't find it again.

So once again please: can we have an "user commands" menu ?

I can do this without this user menu too, but so i have all i need in one app accessible.



I suggest an menu where i can execute commandos to start scripts or execute other apps.
I would like to start f.ex.:
* Notepad.exe   myTips.txt
* rename.vbs
* renameIT.ahk
* createFiles.cmd

Minimum 20 entrys perhaps.


That way we can make Siren scriptable by execute an VBS or AHK with f.ex.

SENDKEYS Ctrl+Shift+P         ; copy current names to the clipboard
...
modify CLIPBOARD              ; modify this names with e.g.  'Split Clipboard'   or  store Clipboard to a new file and parse this with SED or AWK or or or
...
ACTIVATE , Siren_Window_Class   ; set the Siren window active
ACTIVATE , Edit1                          ; set the expression box active
SENDKEYS %C                             ; insert the expression %C

.

.
What do you think? Is this many work for you?

Fine would be if you could show the contains of an sub folder in this user menu
so we could sort the files in sub-sub folder and see the files in sub menus of the user menu.
f.ex.
C:\Siren\Tools\1.cmd
C:\Siren\Tools\Info\tip.txt
C:\Siren\Tools\Favorites\rename.au3

gives the menu
Tools |
        | 1.cmd
        |Info | tip.txt
        |Favorites | rename.au3

Re: Scripting Siren

They have to be executed once for all (not file selection related) or for each selected files ?

6 (edited by Stefan 2007-06-09 10:26:03)

Re: Scripting Siren

I mean this this time independent from any selection to make it easy for you.
The Tools even have nothing to do with your SysListView321 (see f.ex. Notepad myTips.txt have nothing to do with any selection)

I simply use SendKeys in an VBS script to execute 'Ctrl+Shift+P' 
to export the selected current file name to the clipboard
and modify this clipboard contain .....
to put this modified names back to the clip board and use the new variable %C


So, yes
> They have to be executed once for all (not file selection related)


This tool menu is meant simply to have the easy access to execute other apps.
In this app/scripts i use Ctrl+Shift+P and %C or %T to interact with Siren.
So i guess you have no work to implement scripting possibilities into Siren itself.

7 (edited by Stefan 2007-06-09 13:31:08)

Re: Scripting Siren

To automate Siren or to use an script language for advantages renaming we can use an VBS script, or AutoIt or AHK (AutoHotKey)

AutoHotkey can be freely downloaded at www.autohotkey.com
No installation needed if you download the ZIP archive. Just unpack and run the autohotkey.exe

Here is an Script for the upcoming Siren 2.0
which just copies the current selected "current file name" to the clipboard
then parse this clipboard contain line by line
and do .... nothing (that's your part to do).
Then the output is collected together an put back to the clipboard.
Then the focus is set to Siren (if not already, just to be sure),
the expression field is cleared and the new var from Siren 2.0 %C is typed in.
Then the Selection is inverted two times to refresh the "Future names"

;If WinActive("ahk_class Siren_Window_Class")  ; execute this only if Siren has the focus (exec from user menu)
;{
  WinWaitActive, ahk_class Siren_Window_Class  ; wait till the Siren window has the focus
  Send ^+P                                     ; execute the Siren hotkey Ctr+Shift+P to copy the current name to the clipboard

Loop parse, clipboard, `n                      ; split the clipboard containt by CRLF
{
   myLine :=A_LoopField                        ; put each line temporary in the var myLine
 
   ;your code here for each myLine (file name) ; do something with this line i.e. file name
   
   myOut = %myOut%%myLine%`n                   ; collect all myLines for the output
   }
StringTrimRight myOut, myOut, myLine           ; cleanup the line
clipboard := myOut                             ; set the clipboard to your new output
;MsgBox %myOut%
WinActivate,  ahk_class Siren_Window_Class     ; wait till the Siren window has the focus
ControlFocus, Edit1, Siren                     ; give the EXPRESSION combo box the focus
ControlSend, Edit1, {BS}, Siren                ; press an back space to clear the EXPRESSION box
ControlSendRaw, Edit1, `%C, Siren              ; send the Siren shortcut %C
Send ^i                                        ; to refresh Siren invert the selection by press Ctrl+I
Send ^i                                        ;                   and invert it again to the original selection
;}
Return

Note: I'm no expert, so please test this before use with original files.

.