Guest User

Untitled

a guest
Jul 20th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. //AD <-
  2. /*
  3. Simple script that scans the orgDir directory
  4. and unpack all AVI files
  5. The resulting file is put in destDir directory
  6. Using new directorySearch API
  7. */
  8. var app = new Avidemux();
  9. var ds = new DirectorySearch();
  10. var orgDir;
  11. var destDir;
  12. var reg =new RegExp(".$");
  13. /*
  14. This is for Unix
  15. For Windows change to
  16. sep="\\";
  17. reg2=new RegExp("\\.*\\");
  18. */
  19. var sep="/";
  20. var reg2 =new RegExp("\/.*\/");
  21. var extension;
  22. var target;
  23. //
  24. //
  25. //
  26. // select files from original & target directories
  27. //
  28. orgDir=fileReadSelect();
  29. destDir=fileWriteSelect();
  30. orgDir=pathOnly(orgDir);
  31. destDir=pathOnly(destDir);
  32. //
  33. // strip last \\ or //
  34. //
  35. orgDir=orgDir.replace(reg,"");
  36. destDir=destDir.replace(reg,"");
  37. print("orgDir : <"+orgDir+">");
  38. print("destDir : <"+destDir+">");
  39. //
  40. // Go
  41. //
  42. if(ds.Init(orgDir))
  43. {
  44. while(ds.NextFile())
  45. {
  46. // Only process file we want i.e. AVI
  47. if(!ds.isNotFile && !ds.isDirectory && !ds.isHidden && !ds.isArchive && !ds.isSingleDot && !ds.isDoubleDot)
  48. {
  49. extension=ds.GetExtension();
  50. if(extension == "avi")
  51. {
  52. target=ds.GetFileName();
  53. target=destDir+sep+target;
  54. print("***"+ds.GetFileName()+"-->"+target);
  55. processFile(orgDir+sep+ds.GetFileName(),target);
  56. }
  57. //print("File: "+ds.GetFileName()+" is "+ds.GetFileSize()+" bytes, extension "+extension);
  58. }
  59. }
  60. print("We just searched in directory \"" + ds.GetFileDirectory() + "\"");
  61. ds.Close();
  62. }
  63. else
  64. displayError("Error initializing the directory search");
  65. displayInfo("Finished !");
  66. function processFile(filename, targetfile)
  67. {
  68. // Load the file
  69. app.forceUnpack();
  70. app.load(filename);
  71. app.rebuildIndex();
  72. app.audio.delay=0;
  73. app.audio.mixer("NONE");
  74. app.audio.scanVBR();
  75. app.setContainer("AVI_UNP");
  76. app.save(targetfile);
  77. return 1;
  78. }
Add Comment
Please, Sign In to add comment