PAIP1:PAIP Batch renaming JS implementation

Source: Internet
Author: User
Tags copy return split

PAIP Batch renaming JS implementation
Author Attilax, email:1466519819@qq.com; 112237553@qq.com
Why do you use JS? Because scripting language is more convenient, it is more powerful than DOS CMD. PHP can also, one over the environment is relatively large. And JS, each machine already has its operating environment, the direct owner can write, convenient. And JS is more than VBS
More commonly used.
The main process is as follows: Use the FSO for the directory loop, list the files, and then copy to the specified location ... The filename rule is the front plus number, starting at 100. to facilitate sorting.
On the internet to find those software renamed, or the main file name also changed. Or you can just add a suffix. What I need is a prefix number + the original filename.
-------------r.htm----------------------



--------------Renamec426.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+ "

");
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];
}

This article links http://www.cxybl.com/html/wyzz/JavaScript_Ajax/20130729/39370.html

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.