Page 1 of 2

Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 5:25 am
by cgbspender
Hi !

I have those sgf files, downloaded while I was wandering on go websites, and not necessarily english ones...
They are sometimes named as numbers.sgf or by using acronyms LCHvsGL.sgf

I wish I could rename them by using their tags to give a proper name : LeeChangHo-GuLi-Event-Date-Result.sgf for instance.
I found this project on senseis : http://senseis.xmp.net/?SGFOrganizer

but the project is obviously abandonned (too bad !)

So do you know other freewares that would allow me to do this ? renaming them one by one is too time-consuming... especially when you have to rewrite the whole syntax again and again.

Please help !

cgb

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 5:30 am
by DrStraw
I don't know of any, but it seems like it would be a trivial matter to write a short program to do it for anyone with a minimal amount of programming knowledge. I'm sure I could do it in 5 minutes in VB if I knew the syntax of the file.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 5:40 am
by cgbspender
The syntax looks like this in sgf files :

(;GM[1]FF[4]SZ[19]CA[UTF-8]PW[Akedo Kazumi]PB[Hamanaka Takamitsu]WR[6p]BR[4p]KM[0]RE[B+R]EV[Oteai]PC[Nihon Ki-in, Central Japan Branch]DT[1986-05-29]RO[Round1]

With those tags I would like to rename the file(s) so that it becomes :
PW[X]WR[6p] VS PB[Y]BR[4p] - EV[ZZZ]RO[] - DT[YYYY-MM-DD].sgf

For this example, it would give this :

AkedoKazumi 6P VS Hamanaka Takamitsu 4P - Oteai R1 - 19860529.sgf

Best would be to able to rename all the sgf files in a directory, all at once

If someone can help :p

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 6:23 am
by xed_over
DrStraw wrote: I'm sure I could do it in 5 minutes in VB if I knew the syntax of the file.

http://www.red-bean.com/sgf/

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 6:30 am
by kivi
Are you familiar with godrago and kombilo? They organize sgf files into a searchable database. So you don't need to care about filenames to find a game between your favorite pro's.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 7:12 am
by DrStraw
xed_over wrote:
DrStraw wrote: I'm sure I could do it in 5 minutes in VB if I knew the syntax of the file.

http://www.red-bean.com/sgf/


I did not say "if I could find a site which tells me what it is and which I would need to spend some time digesting and understanding." What I meants was if I knew it off the top of my head and did not need to give it any thought. I was merely trying to say it would be very easy for someone fully conversant with the forat.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 7:22 am
by oca
I have done something very similare for my self.
The problem is that I did that with a script written in groovy (and groovy need java to be installed on the computer)...

So two solutions here :

1) you have java on your computer and then I can send you a program and instruction to rename you files.
2) I can do the work for you, but you will then need to send me a zip file with your sgf files.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 7:43 am
by cgbspender
I do use Kombilo, which doesn't allow mass-renaming of the files.
You are right to say it does display the tags, but my original files names are kinda nonsense sometimes, so I'd like to rename them all.

If it were just for me, I wouldn't mind using nonsensical names for those files, as I can view the tags via kombilo, but those files are meant to be sent to macelee (go4go.net) so that he can add them on the website. For convenience issues, I have to have them rewritten, so that macelee won't have to spend months renaiming them. (there is likely to be a few thousands)

cgb

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 7:57 am
by lemon
cgbspender wrote:I do use Kombilo, which doesn't allow mass-renaming of the files.
You are right to say it does display the tags, but my original files names are kinda nonsense sometimes, so I'd like to rename them all.

If it were just for me, I wouldn't mind using nonsensical names for those files, as I can view the tags via kombilo, but those files are meant to be sent to macelee (go4go.net) so that he can add them on the website. For convenience issues, I have to have them rewritten, so that macelee won't have to spend months renaiming them. (there is likely to be a few thousands)

cgb


I'll whip something together tomorrow. I'm currently working on some software that does sgf parsing so it would be easy enough to adapt it to your needs.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 8:16 am
by RobertJasiek
Batch renaming of file names:

ReNamer
http://www.den4b.com/?x=products&product=renamer

Replacing strings within a file:
Use some software with batch processing of Regular Expressions.

Since Pascal script can be added to ReNamer, you might try to use it to create exactly what you want (extract contents of a file to create file names), but I am not sure.

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 9:20 am
by oca
just for curious, a quick and dirty groovy script for renaming files
package oca.go

def srcPath = "D:/my/go/sgf/9x9" // path where the sgf files are
new File(srcPath).eachFile { File file ->
if (file.getName().endsWith(".sgf")) {
def content = file.getText()
def props = content.split(";")[1].replaceAll("\n","")

def pw = findValue("PW", props)
def wr = findValue("WR", props)
def pb = findValue("PB", props)
def br = findValue("BR", props)
def ev = findValue("EV", props)
def ro = findValue("RO", props)
def dt = findValue("DT", props)
// ...
// ...
// do what ever you want here
def newName = "$pw $wr VS $pb $br - $ev $ro - $dt"
file.renameTo(newName+".sgf");
}
}

def findValue(prop,props ) {
def m = props =~ /.*/+prop+/\[(.*?)\]/
return (m.matches()) ? m[0][1] : "___"
}

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 9:22 am
by Stefany93
I wonder whether it will be possible this to be done with Perl? Short program that is rum from the shell/CMD...

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 9:50 am
by cgbspender
That sounds very helpful to my newb ears, oca... but as a newbie, my silly question will be, how to use this ?

I create a text file which I rename as .go and paste all this in it ? and then run it ?
just like for a .sh ?

Re: Looking for a mass-renamer go software

Posted: Fri Mar 14, 2014 10:10 am
by oca
I will post the procedure next week
Bon week end

Re: Looking for a mass-renamer go software

Posted: Sun Mar 16, 2014 2:37 pm
by Rowen
I've used Advanced Renamer before, it works nicely. I think it might do what your wanting.

Here is the URL (its free): http://www.advancedrenamer.com/