It is currently 28 Apr 2024, 01:53
   
Text Size

Card name renamer for linux

Moderators: timmermac, Blacksmith, KrazyTheFox, Agetian, friarsol, CCGHQ Admins

Card name renamer for linux

Postby verot » 04 Mar 2009, 23:00

Hey there,

as we all(?) know, in linux uppercase and lowercase are different, and in the card-pictures.txt there is a lot of files that start with uppercase, I thought about is, first I wanted to rename them manually, but renaming 3-400 cards manually is a pain in you know where =), so I made this program, it will rename all the names in card-pictures.txt and the names of the images to lowercase. I included the source in the zip, and the card-pictures.txt the program created.

It's written in C++, and compiled with GNU GCC compiler.

All you have to do, to copy the namechanger to MTGForge's directory, launch a terminal, go to MTGForge's directory, then ./namechanger, it'll do anything, and it'll make a backup from the original card-pictures.txt.

I hope it's helped =)
Attachments
namechanger.zip
(28.62 KiB) Downloaded 373 times
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby DennisBergkamp » 04 Mar 2009, 23:02

Nice! If you don't mind, I will include this with the next Beta release :)
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby verot » 04 Mar 2009, 23:26

Okay =)

By the way, is there any java book that won't bore me to death by explaining how a hello world program works on 5 pages? =)
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby DennisBergkamp » 05 Mar 2009, 00:01

Alright, cool :)

Don't know of any good Java books, but if you already know C++, Java will be a piece of cake. If you'd like to mess around with the source of MTGForge, I'd recommend maybe reading a few tutorials online, familiarize yourself a bit with the syntax, etc. Then just start reading the code in CardFactory.java (this file has most of the cards), try to understand some of the function calls, and attempt to program some simple cards, using the examples of already-existing cards in CardFactory. Don't be afraid to get your hands dirty and break things.
User avatar
DennisBergkamp
AI Programmer
 
Posts: 2602
Joined: 09 Sep 2008, 15:46
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby GandoTheBard » 05 Mar 2009, 00:01

Even Java For Dummies should suffice for a simple hello world program in Java. :D
visit my personal homepage here: http://outofthebrokensky.com

Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
User avatar
GandoTheBard
Tester
 
Posts: 1043
Joined: 06 Sep 2008, 18:43
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Rob Cashwalker » 05 Mar 2009, 02:03

verot wrote:Hey there,
. . .
It's written in C++, and compiled with GNU GCC compiler.
Welcome to the fold!

Would you expect this program to run under Windows as well? What about Macs with X-based OS? (obviously with recompiling from source...)

I'm a VB programmer, but I've been familiar with C/C++. I picked up Java just from working on MTGForge and using reference material on the web. I haven't actually done a hello world in Java....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Card name renamer for linux

Postby verot » 05 Mar 2009, 10:37

I compiled it with windows, works like charm =)

And yea I messed around with mtgforge's source code, I see a lot of similarities, I understand the code, but I need to learn about built in functions etc =)
Thanks for the tips, i'll search for some java knowledge =), maybe it'll be better, and quicker than a book with 3-400 pages =)

About MAC osX, unfortunately I dont know anybody who have a mac, nor who using osX, I know it's based on UNIX, so I hope It's compilable on a mac too =)
If somebody could compile it with osX that would be great, and if it doesnt work post the errors and I'll fix it =)
Attachments
namechanger.zip
(170.52 KiB) Downloaded 486 times
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Chris H. » 05 Mar 2009, 12:07

verot wrote:I compiled it with windows, works like charm =)

And yea I messed around with mtgforge's source code, I see a lot of similarities, I understand the code, but I need to learn about built in functions etc =)
Thanks for the tips, i'll search for some java knowledge =), maybe it'll be better, and quicker than a book with 3-400 pages =)

About MAC osX, unfortunately I dont know anybody who have a mac, nor who using osX, I know it's based on UNIX, so I hope It's compilable on a mac too =)
If somebody could compile it with osX that would be great, and if it doesnt work post the errors and I'll fix it =)
I have a Mac and use Mac OS X. There is a feature that allows us to use a case sensitive file system. Most of us tend to not use this as it can at times cause problems.

I have not written a line of code or compiled a program since the days of card punch machines. I think that I could accomplish the same goal by selecting all in my text editor and using the feature to convert all to lowercase.

I see that with the recent work we have been doing with the tokens that the name for one of them has changed from "r_3_1_elemental.jpg" to "r_3_1_elemental_haste.jpg".

I will change this in my copy of the card-pictures.txt file and then use the text editor feature to change all to lower case. I will attach this updated file to the appropriate forum message and Dennis can grab a copy for the next distribution.

I want to thank you for bringing this to our attention. We get so busy with the Forge project and everything else in our lives that we sometimes make assumptions that do not always work to everyone's best interests. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Card name renamer for linux

Postby Chris H. » 05 Mar 2009, 13:06

Ouch. :(

It did not work as I had expected. The urls for www.magickartenmarkt.de are case sensitive and when changed to lowercase they will no longer match. I received the old "you must be connected to the internet" message.

What was that I said about assumptions? :wink:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Card name renamer for linux

Postby Rob Cashwalker » 05 Mar 2009, 15:10

ChrisH wrote:I see that with the recent work we have been doing with the tokens that the name for one of them has changed from "r_3_1_elemental.jpg" to "r_3_1_elemental_haste.jpg".
There are two distinct red 3/1 Elemental tokens, one has haste, the other does not.

The urls for www.magickartenmarkt.de are case sensitive
The only URLS that may not be case sensitive are ones pointing specific files (not scripts) running on IIS (M$). Even apache running on windows is case sensitive....

So yeah, vorten - you need to split each line into two substrings, and only enforce the lowercase on the cardname.jpg. Then join them together again. When I wrote a parser for the card-pictures, I actually execute the split using the .jpg as the delimiter, and then trim all whitespace (spaces and tabs) from the beginning of the right-hand substring. Then when I write the file back out, I put the .jpg back in, and precisely two tab characters between.
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Card name renamer for linux

Postby Chris H. » 05 Mar 2009, 15:52

And once we have the card-pictures.txt file correctly converted to just lower case jpg names, it would be nice to have that file attached to a message here on our forums.

This would help to lower the work load for Dennis and the rest of us. :D
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Card name renamer for linux

Postby verot » 05 Mar 2009, 17:13

I included it in both of the zip files I uploaded, the problem is, if you using linux, and you just replace the txt file, there will be a lot of duplicates, and if you have windows installed, it won't like you =), and re-downloading all of the images is a lot of bandwith, and time =)

edit: looks like the forum dont like .txt extension :P

P.S.: here's what the program do -> reads the card name to a string, then reads the url to another, it converts the card name string to lowercase, then writes back everything to a new file, then it it renames all picture's name with the rename() function, it looks up a non-converted card name then renames it to a converted, it renames the extension too, cuz in linux .JPG != .jpg =)

P.S.S.: I've found a good java tutorial on the official java page =) thanks for the tips :). By the way I'm using edit too much =)
Attachments
card-pictures.txt.zip
(17.96 KiB) Downloaded 468 times
User avatar
verot
 
Posts: 14
Joined: 04 Mar 2009, 22:42
Location: <- there
Has thanked: 0 time
Been thanked: 0 time

Re: Card name renamer for linux

Postby Chris H. » 05 Mar 2009, 18:26

verot wrote:I included it in both of the zip files I uploaded, the problem is, if you using linux, and you just replace the txt file, there will be a lot of duplicates, and if you have windows installed, it won't like you =), and re-downloading all of the images is a lot of bandwith, and time =)
I downloaded your updated card-pictures.txt file and I will take a look at it ... I may have to change the jpg name for one of the new token pictures that we have added.

Thank you for the help. Have fun learning how to code in java. :wink:
User avatar
Chris H.
Forge Moderator
 
Posts: 6320
Joined: 04 Nov 2008, 12:11
Location: Mac OS X Yosemite
Has thanked: 644 times
Been thanked: 643 times

Re: Card name renamer for linux

Postby Rob Cashwalker » 05 Mar 2009, 19:43

By the way I'm using edit too much =)
You can never edit a post too much.... Some people don't use it at all around here. On MTGSalvation if you post twice in a row it's an infraction, you're supposed to edit your previous post.

All the code I've done for MTGForge, (and it's not as much as Dennis) has been done without actually compiling and testing. So really... don't be afraid to get your hands dirty in the code. I think the consensus has been to use Eclipse, with Java 1.4. Rares uses some ancient version of JBuilder. I tried JBuilder 2006 and it was much too new - it threw errors on a lot of GUI stuff that's been deprecated, so I could never compile it. Since the last time I made a major submission, I think I got Eclipse working and compiled it once... but I still haven't actually tested anything I've done....
The Force will be with you, Always.
User avatar
Rob Cashwalker
Programmer
 
Posts: 2167
Joined: 09 Sep 2008, 15:09
Location: New York
Has thanked: 5 times
Been thanked: 40 times

Re: Card name renamer for linux

Postby GandoTheBard » 05 Mar 2009, 21:23

Rob Cashwalker wrote:
By the way I'm using edit too much =)
You can never edit a post too much.... Some people don't use it at all around here. On MTGSalvation if you post twice in a row it's an infraction, you're supposed to edit your previous post.

All the code I've done for MTGForge, (and it's not as much as Dennis) has been done without actually compiling and testing. So really... don't be afraid to get your hands dirty in the code. I think the consensus has been to use Eclipse, with Java 1.4. Rares uses some ancient version of JBuilder. I tried JBuilder 2006 and it was much too new - it threw errors on a lot of GUI stuff that's been deprecated, so I could never compile it. Since the last time I made a major submission, I think I got Eclipse working and compiled it once... but I still haven't actually tested anything I've done....
I'm afraid I'm one of those bandits you speak of though I do use edit where I feel it is appropriate. Bug reports I typically don't as I want people to know if there is something new. lol.
visit my personal homepage here: http://outofthebrokensky.com

Listen to my podcast with famed AJ_Impy "Freed from the Real" on http://puremtgo.com
User avatar
GandoTheBard
Tester
 
Posts: 1043
Joined: 06 Sep 2008, 18:43
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Forge

Who is online

Users browsing this forum: No registered users and 153 guests


Who is online

In total there are 153 users online :: 0 registered, 0 hidden and 153 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 153 guests

Login Form