Rename by Reorder

Features wanted...
Post Reply
sysyfry
Posts: 14
Joined: 07 Mar 2018 04:12

Rename by Reorder

Post by sysyfry »

hi,

is it possible to have an option for renaming a file by reorder the name ?

for exemple :
the with a big hat dog.jpg (original name file wrong file name)
the with a big hat dog.jpg (click rename, left click selection, for the "dog" word)
the dog with a big hat.jpg (drag and drop in the correct place)

for exemple :
01-2018-Mar ford.jpg (original name file wrong file name)
01-2018-Mar ford.jpg (click rename, left click selection, for the "-Mar" word)
01-Mar-2018 ford.jpg (drag and drop in the correct place)
01-Mar-2018 ford.jpg (redo, click rename, left click selection, for the "01-Mar-2018" word)
ford 01-Mar-2018.jpg (move the date at the end)

there function like for text this in notepad++,
it's more faster than, erase and re-write the same thing in another place, or even faster/ easy than copy and past


it can be multi lines with copy (CTRL+Click),
for exemple two files :
the dog with a big hat.jpg (original name file)
the cat in house.jpg

the dog with a big hat.jpg
the cat in house.jpg (select "in house")

the dog with a big hat in house.jpg (copy and drag and drop, like CTRL+mouse left click and move)
the cat in house.jpg


Thank you :wink:

also i found some demo gif
Image
Image
Image

sysyfry
Posts: 14
Joined: 07 Mar 2018 04:12

Re: Rename by Reorder

Post by sysyfry »

Hi,

I did a code myself, I hope that can help people and the admin :wink:

It's not perfect, not totally finished, it can be improve, feel free to try... because i will not do it
I tried this code many time, It work great, and safe will not mess with your files.


how use :
1. select file(s), one or multiple files of any type
2. copy paste the code below in the "Scripting / Run Script.."
3. modify
click on "< x >" buttons to do some action on the words : move left / delete word / move right
click on the "word" to modify it
click on the spaces between to "add" a new words (there are a timer, when you finish type it add the word)
4. click on the final name that you can see below, to validate, or click "close"/"or close the window" to quit without changing anything


need to be improved :
-need a dynamic way for the size the window, depend of the screen and the words
-unfortunately the code only understand the spaces " ", between words,
will be good to have/modifiy a custom list of splits characters like "_ - + = . ," but should keeping " { } ( ) [ ] & $ # " as moving items
-when "add" words if there are spaces the code don't understand it's multiple words
-there are no "reset" button
-there are no "undo/redo" button
-there are no "validate" button (but click on the name give a design look)
-when click on the "<" or ">" the mouse cursor should follow
-need a "drag and drop" script but i can't do it
-need a "drag and drop" with copy
-will be good to have all the selected files on the same page, in the same time, so can move/copy words between files.
-for very very very very very very very very very very very very very very very very very very very long name/words can be difficult
-the css ":hover" don't work except for the "<a>", but not for the "<div>" or "<button>" or "<textarea>", this is code work in HTML pages but not in the html() command in XYplorer


another style:
will be cool if we can have directly the "< x >" buttons when renaming the file on the pane (exemple with : ALT+F2)
or
if the window will be more tiny and can open above the file(s) like the "mouse down blow up preview"

Code: Select all

"Reorder Names Of Files HTML Version|:rename"
   //SELECT FILES
   $SELECTED_ITEMS = get("SelectedItemsPathNames", "|"); 
   foreach( $ITEM , $SELECTED_ITEMS , "|") {
      $FILE_PATH = getpathcomponent( $ITEM , "path" );
      $FILE_FILE = getpathcomponent( $ITEM , "file" );
      $FILE_NAME = getpathcomponent( $ITEM , "base" );
      $FILE_PATH_NAME = $FILE_PATH . "\" . $FILE_FILE ;
      $FILE_NAME_LENGHT = strlen( $FILE_NAME ); 
      //HTML PAGE START
      $Variable_html = "";
      $Variable_html = <<<DOX
         <html>
         <head>
            <style>
               *
                  {
                  text-decoration: none;
                  font-family: 'Arial', 'Helvetica', sans-serif;
                  color: #000;
                  font-size: 14px;
                  }
               body
                  {
                  margin: 0px;
                  padding: 0px;
                  background-color: #fff;
                  }
               div 
                  {
                  padding: 3px;
                  margin:  0px 0px 0px 0px;
                  }
               div:hover
                  {
                  }
               table
                  {
                  border: 0px solid red;
                  padding: 0px;
                  margin:  0px;
                  }
               td
                  {
                  border: 0px solid blue;
                  padding: 0px;
                  margin:  0px;
                  }
               button
                  {
                  border: 0px solid blue;
                  padding: 1px 3px 1px 3px;
                  background-color : #bbb;
                  }
               button:hover
                  {
                  background-color : #777;
                  }
               textarea
                  {
                  border: 0px solid blue;
                  width: 100%;
                  height: 100%;
                  padding: 5px 10px 5px 10px;
                  background-color : #bbb;
                  text-align: center;
                  overflow: hidden;
                  }
               textarea:hover
                  {
                  background-color : #777;
                  }
               a 
                  {
                  }
               a:hover
                  {
                  background-color: #9F2;
                  cursor: hand;
                  }
               #ORIGINAL_PATH_NAME
                  {
                  color: fff;
                  background-color : #37B;
                  }
               #ORIGINAL_NAME
                  {
                  background-color : #4cc;
                  }
               #FINAL_NAME
                  {
                  background-color : #7BF;
                  }
            </style>
         </head>
         <body>
            <center>
            <div id="ORIGINAL_PATH_NAME">$FILE_PATH_NAME</div>
            <div id="ORIGINAL_NAME">$FILE_NAME</div>
            </br>
            <div id="TABLE">table</div>
            </br>
            <a id="RETURNED_DATA" href="xys:XXXXXXXXXXXX"><div id="FINAL_NAME"></div></a>
            </br>
            </br>
            <script>
               var FILE_NAME       = "$FILE_NAME" ;
               var FILE_NAME_ARRAY = [""] ;
               var array_pos = 0 ;
               for ( var i=0 ; i<FILE_NAME.length ; i++ )
                  {
                  if ( FILE_NAME.charAt(i) == " " )
                     {
                     array_pos++ ;  
                     FILE_NAME_ARRAY[array_pos] = "" ;
                     }
                  else
                     {
                     FILE_NAME_ARRAY[array_pos] += FILE_NAME.charAt(i) ;
                     };
                  };
               //OUT TABLE START
               function TABLE_OUTPUT (){
                  var TABLE_OUTPUT = "";
                  TABLE_OUTPUT += "<table>";
                  TABLE_OUTPUT += "<tr>";
                  TABLE_OUTPUT += "<td>";
                  TABLE_OUTPUT += "</td>";
                  for ( var i=0 ; i<FILE_NAME_ARRAY.length ; i++ )
                     {
                     TABLE_OUTPUT += "<td>";
                     TABLE_OUTPUT += "<center>";
                     TABLE_OUTPUT += "<button onclick='back(" ;
                     TABLE_OUTPUT += i;
                     TABLE_OUTPUT += ")'><</button>";
                     TABLE_OUTPUT += "<button onclick='del(" ;
                     TABLE_OUTPUT += i;
                     TABLE_OUTPUT += ")'>x</button>";
                     TABLE_OUTPUT += "<button onclick='forward(" ;
                     TABLE_OUTPUT += i;
                     TABLE_OUTPUT += ")'>></button>";
                     TABLE_OUTPUT += "</td>";
                     TABLE_OUTPUT += "<td>";
                     TABLE_OUTPUT += "</td>";
                     };
                  TABLE_OUTPUT += "</tr>";
                  TABLE_OUTPUT += "<tr>";
                  TABLE_OUTPUT += "<td>";
                  TABLE_OUTPUT += "<textarea rows='1' cols='1' onkeyup='add_text(0,this.value)'>";
                  TABLE_OUTPUT += "</textarea>";
                  TABLE_OUTPUT += "</td>";
                  for ( var i=0 ; i<FILE_NAME_ARRAY.length ; i++ )
                     {
                     TABLE_OUTPUT += "<td>";
                     TABLE_OUTPUT += "<textarea rows='1' cols='";
                     TABLE_OUTPUT += 0+FILE_NAME_ARRAY[i].length ;
                     TABLE_OUTPUT += "' onkeyup='modified_text(";
                     TABLE_OUTPUT += i;
                     TABLE_OUTPUT += ",this.value)'>";
                     TABLE_OUTPUT += FILE_NAME_ARRAY[i] ;
                     TABLE_OUTPUT += "</textarea>";
                     TABLE_OUTPUT += "</td>";
                     TABLE_OUTPUT += "<td>";
                     TABLE_OUTPUT += "<textarea rows='1' cols='1' onkeyup='add_text(";
                     TABLE_OUTPUT += i+1;
                     TABLE_OUTPUT += ",this.value)'>";
                     TABLE_OUTPUT += "</textarea>";
                     TABLE_OUTPUT += "</td>";
                     };
                  TABLE_OUTPUT += "</tr>";
                  TABLE_OUTPUT += "</table>";
                  document.getElementById("TABLE").innerHTML = TABLE_OUTPUT ;
                  var FINAL_NAME = "" ;
                  for ( var i=0 ; i<FILE_NAME_ARRAY.length ; i++ )
                     {
                     FINAL_NAME += FILE_NAME_ARRAY[i] ;
                     FINAL_NAME += " " ;
                     };
                  document.getElementById("FINAL_NAME").innerHTML = FINAL_NAME ;
                  document.getElementById("RETURNED_DATA").href   = "xys:" ;
                  document.getElementById("RETURNED_DATA").href   += FINAL_NAME ;
               };
               //OUT TABLE END
               TABLE_OUTPUT ();
               function back (i,val){
                  if (i != 0) {
                     var tempi = FILE_NAME_ARRAY[i-1] ;
                     FILE_NAME_ARRAY[i-1] = FILE_NAME_ARRAY[i] ;
                     FILE_NAME_ARRAY[i] = tempi ;
                     TABLE_OUTPUT ();
                  }; 
               };
               function del (i){
                     FILE_NAME_ARRAY.splice(i, 1) ;
                     TABLE_OUTPUT ();
               };
               function forward (i){
                  if (i < FILE_NAME_ARRAY.length-1 ) {
                     var tempi = FILE_NAME_ARRAY[i+1] ;
                     FILE_NAME_ARRAY[i+1] = FILE_NAME_ARRAY[i] ;
                     FILE_NAME_ARRAY[i] = tempi ;
                     TABLE_OUTPUT ();
                  }; 
               };
               var timeout = null; //set timeout outside the keyup, onkeyup clear timeout and start a new one
               function add_text (i,val){
                     clearTimeout(timeout);
                     timeout = setTimeout(function () {
                        FILE_NAME_ARRAY.splice( i , 0 , val ) ;
                        TABLE_OUTPUT ();
                     }, 1000);
               };
               function modified_text (i,val){
                     clearTimeout(timeout);
                     timeout = setTimeout(function () {
                        FILE_NAME_ARRAY[i] = val ;
                        TABLE_OUTPUT ();
                     }, 1000);
               };
            </script>
         </body>
         </html>
      DOX;
      //HTML PAGE END
      $HTML_RETURNED_DATA = html( $Variable_html , 1800, 300, "Reorder Names Of Files HTML Version");
      //IF NOTHING
      if ( $HTML_RETURNED_DATA == ""){
         status "Nothing Happened", "FF0000", "stop";
         end 1==1; //QUIT
         };
      //IF RETURN
      if ( $HTML_RETURNED_DATA != ""){
         $HTML_RETURNED_DATA = replace($HTML_RETURNED_DATA,"%20"," ");
         renameitem( $HTML_RETURNED_DATA , $ITEM , 1 );
         };
   };



Post Reply