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