Renumbering/Renaming values inside a .xml file?

Advanced Renamer forum
#1 : 11/01-17 03:37
hichemovic
hichemovic
Posts: 4
Hi all, hope you're doing great.

First of all, big thank's to the creator of this amazing and very useful software, much appreciated sir.

Secondly, is there any way to renumber specified values inside a .xml file?

for example, i have this .xml file wich is extracted from SUP file.

a SUP file is Blu-ray subtitles format stands for subtitle bitmap image, and it contains subtitle text graphics that are displayed during movie playback.

so when extracting the SUP file you'll get a folder contains PNG pictures and .txt file that has the timing for those PNG's.

screenshot of the xml file:

http://i.imgur.com/KiGVCMt.png

so the probleme here, is there any solotion or a script that can renumber the values that indicate png pictures inside the xml file?

for example, renumbering from:

<Graphic Width="660" Height="154" X="630" Y="911">0001.png</Graphic>

<Graphic Width="524" Height="155" X="698" Y="910">0002.png</Graphic>

<Graphic Width="543" Height="67" X="688" Y="998">0003.png</Graphic>

to new order:

<Graphic Width="660" Height="154" X="630" Y="911">0999.png</Graphic>

<Graphic Width="524" Height="155" X="698" Y="910">1000.png</Graphic>

<Graphic Width="543" Height="67" X="688" Y="998">1001.png</Graphic>

it uses the same idea from the softwar, selecting the number "position" to "the new number position".

- there's always four caces " xxxx.png ".

- "xxxx.png" always restricted by ><

Thank you in advance.



11/01-17 03:37 - edited 11/01-17 16:13
#2 : 11/01-17 10:47
G. Lambany
G. Lambany
Posts: 186
Reply to #1:
Why not rename the pngs files to match the 0001, 0002, 0003 instead? or am I missing something?


11/01-17 10:47
#3 : 11/01-17 12:25
hichemovic
hichemovic
Posts: 4
Reply to #2:
actualy yes, and i'll try to simplify the situation for you.

i had this two part subtitle for one movie that i want to merge them in one part only.

those two parts subtitle are retail (PGS/SUP), when extracting them we get two folders that contains png pictures, and each folder has it's own .xml file (that includes the timing as i mention befor).

now, in order to merge this two part subtitle in one part only, we had to rename/renumbe the png's from the second part (folder 2) and add them to the folder 1, and i had no problem with that due to advancedrenamer.

as well we have to modifie this new png's order (from second folder) into the .xml (of folder 2).

then after all this steps, i'll just copy the png's from folder 2 to folder 1 as well as the content from .xml (folder 2) to the .xml (folder1), then rebuild the new SUP file with subtitle software.

so the main problem here is how to set the new png's order into the .xml file?
how to replace the pld numbering to the new one.

i uploaded the files that i'm working on it in case you needed them:
http://renzy.me/dbm

and sorry for misleading, i just correct the title, it's an xml file not txt.

thank you so much.


11/01-17 12:25 - edited 11/01-17 16:11
#4 : 11/01-17 16:43
G. Lambany
G. Lambany
Posts: 186
Reply to #3:
here is a quickly coded python script, compiled into an exe:

http://www9.zippyshare.com/v/hR0KCU7b/file.html

usage is as follow:

incrementtext.exe <filename> <increment_number>

so for example:

incrementtext.exe BDN_Index.xml 1000

or with a path:

incrementtext.exe "c:\program files\whatever\BDN_Index.xml" 1000

works on windows only

will output a new file with the _new appened to the filename

nothing is checked in the parameters, so script will crash if you put anything else as parameters, it is designed like this. Only about 10 lines of code, so this isn't rocket science level script.

let me know if it does what you're looking for

I can post the source code if you want

cheers


11/01-17 16:43
#5 : 11/01-17 17:26
hichemovic
hichemovic
Posts: 4
Reply to #4:
much appreciated my friend for the script, and i think it's exactly what i need, but it won't start.

http://i.imgur.com/j9VhslV.png

is there any specified dll files that i should download?

i'm using seven pro x64bits

btw: no need for source code cuz i'm not into programming things. but thank's mate.


11/01-17 17:26
#6 : 11/01-17 17:32
G. Lambany
G. Lambany
Posts: 186
Reply to #5:
no additional dll needed

you need to run it in the command line (cmd.exe)

shift left-click on the folder where the incrementtext script is, select "Open command window here" and type the command as I instructed earlier

glambany@gmail.com if you need more instructions, it'll be easier for me

cheers


11/01-17 17:32
#7 : 11/01-17 18:29
hichemovic
hichemovic
Posts: 4
Reply to #6:
wow it works perfectly, just like what i was looking for.

thanks a lot my friend, you literally saved me. god bless you.

cheers.


11/01-17 18:29
#8 : 11/01-17 19:09
G. Lambany
G. Lambany
Posts: 186
Reply to #7:
Good, just be aware it has a lot of limitations, look at the result file to make sure there isn't any mistakes every times you use it.

It is a very crude script, it does use a regular expression so it has some flexibility to it, but the rest is unchecked, fixed processing

like the zero padding is fixed to 4, could be put into a parameter tho

cheers


11/01-17 19:09 - edited 13/01-17 21:17