PAIP batch renaming JS implementation

Source: Internet
Author: User

PAIP batch renaming JS implementation


Author Attilax, EMAIL: 1466519819@qq.com; 112237553@qq.com

 


Why JS? Because the script language is more convenient, it is more powerful than dos cmd .. PHP is also acceptable. The environment is too large. In JS, each machine has its running environment, which can be directly written by the master for convenience .. JS is more commonly used than VBS ..


The main process is as follows: Use FSO to perform directory loop, list the file list, and COPY to the specified location .. The file name rule is to add a number to the front, starting from 100. To facilitate sorting ..


Find the renamed software online, or change the main file name. Or add a suffix .. What I need is a prefix number + the original file name ..

 


-------------R.htm ----------------------
<Meta http-equiv = "content-type" content = "text/html; charset = UTF-8"/>


<Script src = "renamecw.js"> </script>
<Script>





Var dir = "C: \ Users \ attilax \ Desktop \ new folder (2 )";
Dir = "C :\\ korea font ";
Var dircopy2 = "c: \ korea2 ";
 
RenameC426 (dir );


Document. write ("OK ");


 

 

 


</Script>

 

 

 


-------------- Renamecw..js ----------------

 

 

 

 

 


Function renameC426 (dir)
{


Var fso, f1, ts, s;
Var ForReading = 1;
Fso = new ActiveXObject ("Scripting. FileSystemObject ");
Var f = fso. GetFolder (dir );
Var fc = new Enumerator (f. files );


Var n = parseInt (100 );
For (;! Fc. atEnd (); fc. moveNext ())
{

N ++;
Var file = fc. item ();
Var extname = getExtname (file );
Var mainname = getMainname (file );
Var newfilename = dircopy2 + "\" + n + mainname + "." + extname;
// Document. write (newfilename + "<p> ");
File. copy (newfilename );
}

}

 


Function getExtname (file)
{

Var arr = file. name. split (".");
Return arr [1];
}
Function getMainname (file)
{

Var arr = file. name. split (".");
Return arr [0];
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.