Welcome Guest! To enable all features please Login or Register.
Options
View
Go to last post Go to first unread
Offline pipRaptor  
#1 Posted : Wednesday, November 19, 2014 8:08:32 AM(UTC)
pipRaptor


Rank: YAF Camper

Reputation:

Joined: 11/18/2014(UTC)
Posts: 14
Italy

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
hi, I didn't find a tool to create YAF smiley pak, so I coded it in a very simple C# tool

below there is the code, and I attached the zip with the exe file and the original C# project

you have to put your smiles/emoticons gif files in YAF images\emoticons directory (delete the existing files, if you don't want them) and copy there also the CreateSmileyPack.exe you find in the zip, then launch it

open with a text editor and check the new generated .pak file, because the max length of the names between the [ ... ] brackets is 8 chars, so the CreateSmileyPack takes the last 8 chars if the file name exceeds this length... in case of duplicated names, change the original file name and repeat the procedure

now you can see and upload the pak in your YAF forum settings -> smiles page

Code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CreateSmileyPak
{
    class Program
    {
        static void Main(string[] args)
        {
            using (StreamWriter sw = File.CreateText(@"Emoticons " + DateTime.UtcNow.ToString("yyMMdd HHmmss") + ".pak"))
            {
                foreach (string file in Directory.EnumerateFiles(@".", "*.gif"))
                {
                    // msp_angry.gif=+:Angry=+:[angry]
                    string fileName = file.Replace(@".\", "");
                    string name = fileName.Replace(@".gif", "").Replace(@" ", "_");

                    sw.WriteLine(fileName + "=+:" + name + "=+:[" + name.Substring(Math.Max(0, name.Length - 8)) + "]");
                    Console.WriteLine(file + " OK!");
                }
            }

            Console.WriteLine("\n-----\nPress a key to close...");
            Console.ReadKey();
        }
    }
}

Edited by user Sunday, November 23, 2014 2:01:45 AM(UTC)  | Reason: spelling error

File Attachment(s):
CreateSmileyPak.zip (37kb) downloaded 52 time(s).
Sponsor
Offline pipRaptor  
#2 Posted : Thursday, November 20, 2014 10:28:30 AM(UTC)
pipRaptor


Rank: YAF Camper

Reputation:

Joined: 11/18/2014(UTC)
Posts: 14
Italy

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
I coded another trick

since I had a lot of gif with long names (more than 8 chars) I programmed another C# tool, it checks the file name length and it asks you to change the longest

below there is the code and I attach a zip with the EXE and with the complete C# project

extract the exe file and put it in your smiles/emoticons directory, run it and that's all!
you can also stop the work when you are tired, close the program and restart it when you want

Code:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Rename8CharFile
{
    class Program
    {
        static void Main(string[] args)
        {
            foreach (string oldFile in Directory.EnumerateFiles(@".", "*.gif"))
            {
                string newName = string.Empty;
                string oldName = Path.GetFileNameWithoutExtension(oldFile);

                while (oldName.Length > 8)
                {
                    Console.Write("File name: " + oldName);
                    Console.Write(" - New name? ");
                    newName = Console.ReadLine();

                    try
                    {
                        string newFile = oldFile.Replace(oldName, newName);
                        File.Move(oldFile, newFile);
                        oldName = newName;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }

                Console.WriteLine(oldName + " OK!");
            }
        }
    }
}

Edited by moderator Saturday, November 22, 2014 9:37:12 AM(UTC)  | Reason: Text correction

File Attachment(s):
Rename8CharFile.zip (36kb) downloaded 43 time(s).
Rss Feed  Atom Feed
Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Notification

Icon
Error