You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 54 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. function CBuildSource(Folder, Ext){
  2. this.Ext = Ext;
  3. this.fso = WScript.CreateObject("Scripting.FileSystemObject");
  4. this.Folder = this.fso.GetFolder(Folder);
  5. this.SourceCheckExtRegExp = new RegExp("^" + this.Ext + "$", "i");
  6. this.CheckExt = function(Folder){
  7. return this.fso.GetExtensionName(Folder.Name).match(this.SourceCheckExtRegExp);
  8. };
  9. this.GetSourceFoldersEnumerator = function(){
  10. return new Enumerator(this.Folder.SubFolders);
  11. };
  12. };
  13. function CBuilder(FolderName){
  14. this.fso = WScript.CreateObject("Scripting.FileSystemObject");
  15. this.WshShell = WScript.CreateObject("WScript.Shell");
  16. this.FolderExists = false;
  17. this.FolderName = FolderName;
  18. if (FolderName.length == 0){
  19. this.FolderName = ".";
  20. };
  21. this.GetNewFullFileName = function(FileName){
  22. if (!this.FolderExists){
  23. if (!this.fso.FolderExists(this.FolderName)){
  24. this.Folder = this.fso.CreateFolder(FolderName);
  25. this.FolderExists = true;
  26. }else{
  27. this.Folder = this.fso.GetFolder(this.FolderName);
  28. this.FolderExists = true;
  29. };
  30. };
  31. return this.fso.BuildPath(this.Folder.Path, this.fso.GetFileName(FileName));
  32. };
  33. this.GetCommandLine = function(SourceFolder, FileName){
  34. return "7za a -tzip \""+ FileName + "\" \"" + SourceFolder + "\\*.*\"" ;
  35. };
  36. this.ProcessFolder = function(Folder){
  37. var NewFileName = this.GetNewFullFileName(Folder.Name);
  38. var FolderFullName = Folder.Path;
  39. if (this.fso.FileExists(NewFileName)){
  40. this.fso.DeleteFile(NewFileName);
  41. };
  42. var CommandLine = this.GetCommandLine(FolderFullName, NewFileName);
  43. WScript.Echo(CommandLine);
  44. var Pipe = this.WshShell.Exec(CommandLine);
  45. while(!Pipe.StdOut.AtEndOfStream){
  46. WScript.StdOut.WriteLine(Pipe.StdOut.ReadLine());
  47. };
  48. }
  49. };
  50. var Source = new CBuildSource(".", "zmp");
  51. var Builder = new CBuilder(".\\.bin");
  52. var oFiles = Source.GetSourceFoldersEnumerator();
  53. for (; !oFiles.atEnd(); oFiles.moveNext()){
  54. var oFile = oFiles.item();
  55. if (Source.CheckExt(oFile)){
  56. Builder.ProcessFolder(oFile);
  57. };
  58. };