Results 1 to 8 of 8

Thread: [Tool] Creating a World - Java Script for lower case Conversion

  1. #1
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default [Tool] Creating a World - Java Script for lower case Conversion

    Introduction
    With the release of the Linux version of M2TW it had become mandatory for mods to have all file and directory names in lower case. For existing mods this would be very labor intensive unless the process was automated, hence this Java script has been developed - all credit for the original code goes to bovi. The original code used upper case as it was intended for use in the Windows environment only, changing this to lower case and adjusting code references accordingly is the only code stuff by me.


    Using the Script
    Java SetupThe script has been successfully run on Java version jre1.8.0_121 in a 64bit Windows10 environment. It is unlikely that there is a computer that does not have one or the other Java version, but just in case here is the link to 'Java Downloads for All Operating Systems'.

    Getting the script to do it's stuffDue to the variety of Java installations the Script Download comes in a test directory set up (Java Script Test) where it is recommended to test the functionality of the script before putting it to work. Simply extract the download on your desktop with a compression tool like 7Zip and run\double click the filenametolowercase.bat file to test. The DOS window will remain open (paused) to enable reading of error\success messages and will close on pressing any button.
    Running the script is as easy as copying all three filenametolowercase files into the root of the directory you wish to convert and running\double clicking the BAT (batch) file.

    RemarksI have not tested this script in a Linux environment and attempts by Socrates1984 have not been successful due to some problems with the Java installation for Linux. Any feed back in this regard is highly welcome.

    Last edited by Gigantus; February 16, 2017 at 10:15 AM.










  2. #2
    Foederatus
    Join Date
    Jul 2015
    Location
    Istanbul, Turkey
    Posts
    30

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Quote Originally Posted by Gigantus View Post
    With the release of the Linux version of M2TW it had become mandatory for mods to have all file and directory names in lower case. For existing mods this would be very labor intensive unless the process was automated, hence this Java script has been developed - all credit for the original code goes to bovi. The original code used upper case as it was intended for use in the Windows environment only, changing this to lower case and adjusting code references accordingly is the only code stuff by me.
    Is this for people that create mods (So that their mods can run on Linux.) or for people trying to run others' mods on Linux (So that they can make the mods they've installed work on Linux by using the script?


    Quote Originally Posted by Gigantus View Post
    Java SetupThe script has been successfully run on Java version jre1.8.0_121 in a 64bit Windows10 environment. It is unlikely that there is a computer that does not have one or the other Java version, but just in case here is the link to 'Java Downloads for All Operating Systems'.
    Java may be ubiquitous on Windows but it is non-free on Debian, for example. Or, did you also include its free software implementations in what you meant? If so, that includes many Linux users as well, yes. If not, the answer to my previous question was the former, I guess then.


    Quote Originally Posted by Gigantus View Post
    Getting the script to do it's stuffDue to the variety of Java installations the Script Download comes in a test directory set up (Java Script Test) where it is recommended to test the functionality of the script before putting it to work. Simply extract the download on your desktop with a compression tool like 7Zip and run\double click the filenametolowercase.bat file to test. The DOS window will remain open (paused) to enable reading of error\success messages and will close on pressing any button.
    Running the script is as easy as copying all three filenametolowercase files into the root of the directory you wish to convert and running\double clicking the BAT (batch) file.
    Seeing that you refer to 7-zip and DOS, this is not meant for Linux users, then.


    Quote Originally Posted by Gigantus View Post
    RemarksI have not tested this script in a Linux environment and attempts by Socrates1984 have not been successful due to some problems with the Java installation for Linux. Any feed back in this regard is highly welcome.
    Well, this part's the actual reason I'm posting My operating system is Debian GNU/Linux and and computer architecture 32-bit. WineHQ (https://appdb.winehq.org/objectManag...sion&iId=31528) rightly states that Internet Explorer 8 is needed to proceed with the installation. Now, I'm not a technical person at all (certainly far less than Socrates1984), but I found installing IE8 with Wine simply impossible. Looking at WineHQ (https://appdb.winehq.org/objectManag...sion&iId=17187), it seems that an Arch Linux user has had more luck with it.
    May I ask why the script strictly needs Java 8 (Doesn't it just add functional programming features? And if the script does use functional programming, then why use Java?); because perhaps the older versions might be easier to work with Wine. I didn't download the script, so I don't know if it already has the source code; but if not, perhaps you can post it so that someone can write it in another language (It seems to be a simple script from what I gather, so I'm hopeful about this ).

    Slightly off-topic, but this has also prevented me from using the batch files provided by Europa Barbarorum II (except for the one that is used to run the game, seemingly). Should I post this on their forum? I'm fine with not being able to use extra features but it would be nice for EBII to be compatible with Linux if that's not asking for too big a favor

    By the way, thank you all for helping GNU/Linux users; I was pleasantly surprised to find a(n) (albeit small) Linux subforum here, it's much appreciated

  3. #3
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    I have no hands on experience with Linux so let me respond as good as I can
    Quote Originally Posted by magnificent walrus View Post
    Is this for people that create mods (So that their mods can run on Linux.) or for people trying to run others' mods on Linux (So that they can make the mods they've installed work on Linux by using the script?
    It's intended for both. The happy arrangement would be that DOS modders will run their mod through this script before offer it as download.

    Quote Originally Posted by magnificent walrus View Post
    Java may be ubiquitous on Windows but it is non-free on Debian, for example. Or, did you also include its free software implementations in what you meant? If so, that includes many Linux users as well, yes. If not, the answer to my previous question was the former, I guess then.

    Seeing that you refer to 7-zip and DOS, this is not meant for Linux users, then.
    It's written from a DOS perspective with the hope that a Linux user can adapt it.

    Quote Originally Posted by magnificent walrus View Post
    Well, this part's the actual reason I'm posting My operating system is Debian GNU/Linux and and computer architecture 32-bit. WineHQ (https://appdb.winehq.org/objectManag...sion&iId=31528) rightly states that Internet Explorer 8 is needed to proceed with the installation. Now, I'm not a technical person at all (certainly far less than Socrates1984), but I found installing IE8 with Wine simply impossible. Looking at WineHQ (https://appdb.winehq.org/objectManag...sion&iId=17187), it seems that an Arch Linux user has had more luck with it.
    May I ask why the script strictly needs Java 8 (Doesn't it just add functional programming features? And if the script does use functional programming, then why use Java?); because perhaps the older versions might be easier to work with Wine. I didn't download the script, so I don't know if it already has the source code; but if not, perhaps you can post it so that someone can write it in another language (It seems to be a simple script from what I gather, so I'm hopeful about this ).
    I am not sure if Java 8 is compulsory, I mentioned the version as that is the one I ran the script with. AS to IE8 for: not the faintest idea.

    Quote Originally Posted by magnificent walrus View Post
    Slightly off-topic, but this has also prevented me from using the batch files provided by Europa Barbarorum II (except for the one that is used to run the game, seemingly). Should I post this on their forum? I'm fine with not being able to use extra features but it would be nice for EBII to be compatible with Linux if that's not asking for too big a favor

    By the way, thank you all for helping GNU/Linux users; I was pleasantly surprised to find a(n) (albeit small) Linux subforum here, it's much appreciated
    This script originated from the EBII team, is used by them, and bovi is a member of that team. The best bet would be to send him a PM with a link to this thread unless there is a similar thread in the EBII forum.










  4. #4

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Hi, sorry for my very late reply. Haven't been on the forums for a while. Hope this helps!

    DO NOTE THIS: You shouldn't really need this tool when working on Linux. There are more powerful command line tools there than on Windows, so Java should be overkill. I'm sure you can find a way that works for you on this Stack Overflow thread or somewhere else. But I'm answering the rest of your queries in case you do need it still.

    Quote Originally Posted by magnificent walrus View Post
    Is this for people that create mods (So that their mods can run on Linux.) or for people trying to run others' mods on Linux (So that they can make the mods they've installed work on Linux by using the script?
    This is for people who create mods. It would be a waste if a mod creator would lay it on each of their users to convert filenames themselves, when it is far more efficient for it to be done only once by the creator. If there are any upper case letters in the file names, the mod will fail to run on Linux (I'm told - I haven't tried any Total War game on Linux myself). Converting to lower case will make no difference whatsoever on a Windows computer and is necessary for Linux, so basically there is no downside to converting them all to lower case before releasing the mod.

    Quote Originally Posted by magnificent walrus View Post
    Java may be ubiquitous on Windows but it is non-free on Debian, for example. Or, did you also include its free software implementations in what you meant? If so, that includes many Linux users as well, yes. If not, the answer to my previous question was the former, I guess then.
    I'm fairly sure that Oracle does not charge anyone for downloading the Java runtime, regardless of OS. According to this page, on Debian it should be as easy as writing a command line to install Java:

    apt-get install default-jre


    Quote Originally Posted by magnificent walrus View Post
    Seeing that you refer to 7-zip and DOS, this is not meant for Linux users, then.
    The script is in Java, so it doesn't (shouldn't!) care about which OS you run on. There are free applications on Linux for packing and unpacking zip files, such as gzip, bzip and more. I believe at least one of those come preinstalled on any distribution. On some older versions of Windows, the file manager does not transparently recognize zip files and allow you to delve into their contents, hence pointing to 7-zip as a free application for the purpose of unpacking.

    Quote Originally Posted by magnificent walrus View Post
    Well, this part's the actual reason I'm posting My operating system is Debian GNU/Linux and and computer architecture 32-bit. WineHQ (https://appdb.winehq.org/objectManag...sion&iId=31528) rightly states that Internet Explorer 8 is needed to proceed with the installation.
    Wait, what? Why are you mixing Wine and Internet Exploder into this? Under no circumstance should Wine be necessary for changing some file names !

    Quote Originally Posted by magnificent walrus View Post
    May I ask why the script strictly needs Java 8
    It doesn't. It should run on any Java version since 1.3 or something, I guess. It's a very simple program.

    Quote Originally Posted by magnificent walrus View Post
    I didn't download the script, so I don't know if it already has the source code;
    It does. I haven't checked if there are any changes made by Gig, but this here is my code as used on EB before release:
    Spoiler Alert, click show to read: 
    Code:
    import java.io.File;
    
    public class FileNameToLowercase
    {
        public static void main(String[] args)
        {
            doFolder(".");
        }
    
        public static void doFolder(String path)
        {
            File[] filesAndFolders = new File(path).listFiles();
            for(File currentFile : filesAndFolders)
            {
                if(currentFile.getName().equals("FileNameToLowercase.class"))
                    continue;
                if(currentFile.isDirectory())
                    doFolder(path + File.separator + currentFile.getName());
                if(!currentFile.getName().equals(currentFile.getName().toLowerCase()))
                    currentFile.renameTo(new File(path + File.separator + currentFile.getName().toLowerCase()));
            }
        }
    }

    Its concept is simple: For the folder where this script is located and all subfolders beneath it in the tree, list all the files. For each file, check if converting to lower case would change the file name. If so, rename the file to the lower case name. Make a special excemption for the actual java script file.

    Quote Originally Posted by magnificent walrus View Post
    Slightly off-topic, but this has also prevented me from using the batch files provided by Europa Barbarorum II (except for the one that is used to run the game, seemingly).
    I don't know which batch files you are talking about. You would have to be more specific.

    Edit: Oh, by the way, please ping me on totalwar.org again if you need anything else here, I'm hardly ever on twcenter anymore.
    Last edited by bovi; May 30, 2017 at 06:36 AM.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  5. #5
    Gigantus's Avatar I am not special - I am a limited edition.
    Patrician Moderator Emeritus Administrator Emeritus

    Join Date
    Aug 2006
    Location
    Goa - India
    Posts
    53,095
    Blog Entries
    35

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Quote Originally Posted by bovi View Post
    I haven't checked if there are any changes made by Gig, but this here is my code as used on EB before release:
    Spoiler Alert, click show to read: 
    Code:
    import java.io.File;
    
    public class FileNameToLowercase
    {
        public static void main(String[] args)
        {
            doFolder(".");
        }
    
        public static void doFolder(String path)
        {
            File[] filesAndFolders = new File(path).listFiles();
            for(File currentFile : filesAndFolders)
            {
                if(currentFile.getName().equals("FileNameToLowercase.class"))
                    continue;
                if(currentFile.isDirectory())
                    doFolder(path + File.separator + currentFile.getName());
                if(!currentFile.getName().equals(currentFile.getName().toLowerCase()))
                    currentFile.renameTo(new File(path + File.separator + currentFile.getName().toLowerCase()));
            }
        }
    }
    It's still the same code - I just made adjustments to allow for the lower case of the supporting files, eg the class file, to make it Linux compatible.

    Thanks for the input!










  6. #6
    Foederatus
    Join Date
    Jul 2015
    Location
    Istanbul, Turkey
    Posts
    30

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Quote Originally Posted by bovi View Post
    Hi, sorry for my very late reply. Haven't been on the forums for a while. Hope this helps!
    I was just sharing feedback because Gigantus specifically asked for such.

    Quote Originally Posted by bovi View Post
    DO NOTE THIS: You shouldn't really need this tool when working on Linux. There are more powerful command line tools there than on Windows, so Java should be overkill.
    Sorry, didn't know the code was this simple.

    Quote Originally Posted by bovi View Post
    This is for people who create mods. It would be a waste if a mod creator would lay it on each of their users to convert filenames themselves, when it is far more efficient for it to be done only once by the creator.
    Well, some EB patches and fixes were released separately, for example; so, I guess it can sometimes be the other way around.

    Quote Originally Posted by bovi View Post
    I'm fairly sure that Oracle does not charge anyone for downloading the Java runtime, regardless of OS. According to this page, on Debian it should be as easy as writing a command line to install Java:
    I meant that the version in Oracle's site does not have a libre license; the one in Debian's repository is, as I've said, a free (libre) implementation (icedtea) of openjdk. You can read on what Debian considers free here: https://www.debian.org/social_contract#guidelines

    Quote Originally Posted by bovi View Post
    There are free applications on Linux for packing and unpacking zip files, such as gzip, bzip and more. I believe at least one of those come preinstalled on any distribution.
    I know, I used that paragraph of Gigantus' only in order to deduce the audience as Windows users, nothing more. He's already clarified this in his reply since then.

    Quote Originally Posted by bovi View Post
    Wait, what? Why are you mixing Wine and Internet Exploder into this? Under no circumstance should Wine be necessary for changing some file names !
    Well, you're right, but the problem with installing Java 8 with Wine is more general and this was what Gigantus asked for feedback about and which also prevented me from running EB II's batch files (other than that which is used to run the game it seems) strictly requiring the 8th version of Java.

    Quote Originally Posted by bovi View Post
    I don't know which batch files you are talking about. You would have to be more specific.
    I'm a bit surprised that you say that; I'm talking about the files with the .bat extension in the mod folder (mods/ebii): launch recruitment viewer, launch windowed mode switcher, launch, launch-cine-edit, launch-cine-render. I've since moved my Total War installation to a Windows partition out of necessity, so I cannot provide further feedback; but it would be nice if the mod's batch files didn't require Java 8 for the benefit of the few Wine users. Thank you.

  7. #7

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Quote Originally Posted by magnificent walrus View Post
    Well, some EB patches and fixes were released separately, for example; so, I guess it can sometimes be the other way around.
    You confuse me. Are you saying that those patches and fixes included some file names with uppercase letters in them? If so, that was definitely a mistake by those who provided them, but I don't see why you would bring it up. If that's not what you were getting at, I have no idea what you are talking about.

    Whatever the case, I'll reiterate that the mod creator should definitely be the one to ensure the file names in the mod (s)he releases do not contain any uppercase, so that everyone who downloads for Linux does not have to do it themselves. That means one piece of work, instead of potentially thousands of pieces of work (one for each download).

    Quote Originally Posted by magnificent walrus View Post
    I meant that the version in Oracle's site does not have a libre license; the one in Debian's repository is, as I've said, a free (libre) implementation (icedtea) of openjdk. You can read on what Debian considers free here: https://www.debian.org/social_contract#guidelines
    Anyone can run Oracle's Java if they want, without paying for it and as far as I can see without incurring any debt to any demon. This means anyone can use this simple renaming tool and it is then not restricted to Windows, even as unnecessary as the tool may be outside of Windows as there exist better command line alternatives to it. I can't see why the fine details of what kind of "free" Java satisfies, matters too much in this case.

    Quote Originally Posted by magnificent walrus View Post
    Well, you're right, but the problem with installing Java 8 with Wine is more general and this was what Gigantus asked for feedback about and which also prevented me from running EB II's batch files (other than that which is used to run the game it seems) strictly requiring the 8th version of Java.
    I'm sure that emulating with Wine has many general problems, with Java and otherwise, but as far as I can see it is irrelevant to this particular tool as Wine is not required to run that.

    Quote Originally Posted by magnificent walrus View Post
    I'm a bit surprised that you say that; I'm talking about the files with the .bat extension in the mod folder (mods/ebii): launch recruitment viewer, launch windowed mode switcher, launch, launch-cine-edit, launch-cine-render. I've since moved my Total War installation to a Windows partition out of necessity, so I cannot provide further feedback; but it would be nice if the mod's batch files didn't require Java 8 for the benefit of the few Wine users. Thank you.
    Right, I understand. EB's batch files are somewhat off topic here, but whatever, it's not looking to be a long conversation anyway at this point. In my EB file tree there are well over 10 scripts I use more or less regularly, and those include only one of those you listed: launch, which does not use Java at all. Of particular note is that some of those scripts I use require the Java version not to be Java 8, it must be 7 or below. But enough about the reasons for me asking for specification.

    I believe the launcher.wsf javascript used in both of the cine-scripts was written before Java 8 even existed, so it should work fine with at least Java 7, probably also earlier versions. It wouldn't surprise me if they even failed with Java 8 like some of the others I talked about above.

    I know hardly anything about the recruitment viewer and the windowed mode switcher, as I haven't been involved with making those at all. I just tested them with Java 7 though, and they failed, but I think that is only because they have been specifically compiled to that version. I imagine they don't really use any Java 8 specific function and so could easily be compiled for an earlier version, but I don't see the source code for them anywhere in source control. I see that their jar files have been made by Rafkos though, so could you ask him about it on the org? I think he should be able to help out with them.

    Having problems getting EB2 to run? Try these solutions.
    ================
    I do NOT answer PM requests for help with EB. Ask in a new help thread in the tech help forum.
    ================
    I think computer viruses should count as life. I think it says something about human nature that the only form of life we have created so far is purely destructive. We've created life in our own image. - Stephen Hawking

  8. #8
    Foederatus
    Join Date
    Jul 2015
    Location
    Istanbul, Turkey
    Posts
    30

    Default Re: [Tool] Creating a World - Java Script for lower case Conversion

    Quote Originally Posted by bovi View Post
    You confuse me. Are you saying that those patches and fixes included some file names with uppercase letters in them?
    Excuse my brevity, I meant that those patches and fixes were expected to be applied by the users themselves because it was harder to make a new installer for the developers, I heard. So, perhaps it can sometimes be the other way around?

    Quote Originally Posted by bovi View Post
    Anyone can run Oracle's Java if they want, without paying for it and as far as I can see without incurring any debt to any demon.
    That was really off-topic of me, sorry about that, you can disregard that bit.

    Quote Originally Posted by bovi View Post
    I'm sure that emulating with Wine has many general problems, with Java and otherwise, but as far as I can see it is irrelevant to this particular tool as Wine is not required to run that.
    Yes, it does have many problems, unfortunately, so much so that I've finally quit. I've only learned that this tool was actually very simple after reading your reply, but still wanted to bring attention to it because it caused me problems with EB scripts too.

    Quote Originally Posted by bovi View Post
    I believe the launcher.wsf javascript used in both of the cine-scripts was written before Java 8 even existed, so it should work fine with at least Java 7, probably also earlier versions. It wouldn't surprise me if they even failed with Java 8 like some of the others I talked about above.
    Unfortunately all of them apart from the game itself says that I need the version 8.

    Quote Originally Posted by bovi View Post
    I know hardly anything about the recruitment viewer and the windowed mode switcher, as I haven't been involved with making those at all. I just tested them with Java 7 though, and they failed, but I think that is only because they have been specifically compiled to that version. I imagine they don't really use any Java 8 specific function and so could easily be compiled for an earlier version, but I don't see the source code for them anywhere in source control. I see that their jar files have been made by Rafkos though, so could you ask him about it on the org? I think he should be able to help out with them.
    I'll let him know about this issue affecting Wine users, thank you.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •