Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Rename PATTERN * TO *
- @script jscript
- // Dopus rename script (http://www.gpsoft.com.au/)
- // Add folder name after file name
- DOpus.ClearOutput();
- DOpus.output(DOpus.version);
- function Rename::GetNewName2(strFileName, strFilePath, _fIsFolder, strOldName, strNewName) {
- if(_fIsFolder){
- DOpus.output(strFileName +" Is Folder");
- return strFileName;
- }
- parentFolder = GetPathLastFolder(new String(strFilePath)).folder;
- var fname = strFileName.replace(/(.*)(\.[^.]+)$/, "$1");
- var fextn = strFileName.replace(/(.*)(\.[^.]+)$/, "$2");
- DOpus.output("fname: "+fname + fextn);
- var re = new RegExp(parentFolder+'$');
- //DOpus.output("regExp: "+fname.match(re));
- if (fname.match(re)) {
- DOpus.output("Not Rename " + strFileName);
- return strFileName
- }
- DOpus.output("Rename " + strFileName + " to " + fname +' '+ parentFolder + fextn);
- return fname +' '+ parentFolder + fextn;
- }
- function GetPathLastFolder(mypath) {
- mypath = mypath.replace(/(^(\s|\/|\\)+)|((\s|\/|\\)+$)/g, "");
- lastIndex = mypath.lastIndexOf('\\');
- if (lastIndex == -1 || (lastIndex + 1) == mypath.length) return {
- folder: mypath,
- parentPath: ""
- };
- return {
- folder: mypath.substring(lastIndex + 1),
- parentPath: mypath.substring(0, lastIndex)
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement