Advertisement
Guest User

rename_button1

a guest
Jun 7th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Rename PATTERN * TO *
  2. @script jscript
  3.  
  4. // Dopus rename script (http://www.gpsoft.com.au/)
  5. // Add folder name before file name
  6.  
  7. DOpus.ClearOutput();
  8. DOpus.output(DOpus.version);
  9.  
  10. function Rename::GetNewName2(strFileName, strFilePath, _fIsFolder, strOldName, strNewName) {
  11.  
  12.     if (_fIsFolder) {
  13.         DOpus.output(strFileName + " Is Folder");
  14.         return strFileName;
  15.     }
  16.     parentFolder = GetPathLastFolder(new String(strFilePath)).folder;
  17.     if (strFileName.indexOf(parentFolder) === 0) {
  18.         DOpus.output("Not Rename " + strFileName);
  19.         return strFileName
  20.     }
  21.     DOpus.output("Rename " + strFileName + " to " + parentFolder + ' ' + strFileName);
  22.     return parentFolder + ' ' + strFileName;
  23. }
  24.  
  25. function GetPathLastFolder(mypath) {
  26.     mypath = mypath.replace(/(^(\s|\/|\\)+)|((\s|\/|\\)+$)/g, "");
  27.     lastIndex = mypath.lastIndexOf('\\');
  28.     if (lastIndex == -1 || (lastIndex + 1) == mypath.length) return {
  29.         folder: mypath,
  30.         parentPath: ""
  31.     };
  32.     return {
  33.         folder: mypath.substring(lastIndex + 1),
  34.         parentPath: mypath.substring(0, lastIndex)
  35.     };
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement