本帖最后由 pcl_test 于 2016-5-10 23:33 编辑
假设目标文件夹为空文件夹- /*&cls
- @echo off
- set "fd=C:\fun"
- if not exist "%fd%" md "%fd%"
- for /f "tokens=1*delims=|" %%a in ('dir /a-d/b/s *.jpg *.gif^|cscript -nologo -e:jscript "%~f0"') do copy "%%a" "%fd%\%%b"
- pause&exit
- */
-
- var a = {}, s = '';
- try{
- var files = WSH.StdIn.ReadAll().split(/\r\n/);
- for(var i = 0; i<files.length; i++){
- var f = files[i].replace(/^.+\\([^\\]+)(\.[^\.]+)$/, function($0, $1, $2){
- var name = ($1 + $2).toLowerCase();
- if(!a[name]){
- a[name] = 1;return $0 +'|'+ $1 +$2;
- }else{
- a[name]++;return $0 +'|'+ $1 +'_'+ (a[name]-1) +$2;
- }
- })
- s += f+'\r\n';
- }
- WSH.echo(s)
- }catch(e){}
复制代码
|