Created
February 26, 2014 08:25
-
-
Save DavidDeSloovere/9225743 to your computer and use it in GitHub Desktop.
This ScriptCS code copies files into a folder while renaming them, and then compresses them into a zip file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO OFF | |
CLS | |
ECHO --- | |
ECHO This command needs scriptcs (see http://scriptcs.net/) | |
ECHO If it is not installed you will get an error | |
ECHO --- | |
scriptcs PrepResourceFilesForTranslator.csx | |
ECHO --- | |
PAUSE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#r "System.IO.Compression.FileSystem.dll" | |
using System; | |
using System.IO; | |
using System.IO.Compression; | |
public void CopyFile(string relativeSourceFolder, string sourceFileName, string destinationFileName) { | |
var sourceFolder = Path.Combine(rootPath, relativeSourceFolder); | |
var sourcePath = Path.Combine(sourceFolder, sourceFileName); | |
var destPath = Path.Combine(tempPath, destinationFileName); | |
File.Copy(sourcePath, destPath, true); | |
Console.WriteLine(" " + destinationFileName); | |
} | |
Console.WriteLine("*** Preparing resource files to send to translator."); | |
string currentPath = Directory.GetCurrentDirectory(); | |
string rootPath = Directory.GetParent(currentPath).FullName; | |
string setName = "resources-" + DateTime.Now.ToString("yyyyMMdd-HHmm"); | |
string desktopPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); | |
string tempPath = Path.Combine(desktopPath, setName); | |
Directory.CreateDirectory(tempPath); | |
Console.WriteLine("Copying files:"); | |
CopyFile("Source/src/ProjectName.Model/Properties", "resources.resx", "Model.nl-BE.resx"); | |
CopyFile("Source/src/ProjectName.Model/Properties", "resources.fr-BE.resx", "Model.fr-BE.resx"); | |
CopyFile("Source/src/ProjectName.WpfClient/Properties", "resources.resx", "Client.nl-BE.resx"); | |
CopyFile("Source/src/ProjectName.WpfClient/Properties", "resources.fr-BE.resx", "Client.fr-BE.resx"); | |
var zipPath = Path.Combine(desktopPath, setName + ".zip"); | |
System.IO.Compression.ZipFile.CreateFromDirectory(tempPath, zipPath); | |
Directory.Delete(tempPath, true); | |
Console.WriteLine("Zip file created with the 4 resx files:"); | |
Console.WriteLine(" " + zipPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment