|
发表于 2008-10-20 19:03:31
|
显示全部楼层
将文件内容显示一下:
FileRen.bat- @REM
- @REM 将形式为 歌手--歌曲 类型的文件改成 歌手\歌曲,歌手变成目录。
- @REM
- @REM
- @REM 例如:
- @REM G:\新歌需要整理1\大陆\李子璇--有没有一种爱让人不流泪(原版伴奏).mpg
- @REM
- @REM 修改成
- @REM
- @REM G:\新歌需要整理1\大陆\李子璇\有没有一种爱让人不流泪(原版伴奏).mpg
- @REM
- @REM
- @REM
- @REM 注意:
- @REM --也可换成其它的字符,在FileRen.vbs中更改下一行:
- @REM
- @REM Const constType="--"
- CScript //nologo FileRen.vbs
复制代码 FileRen.vbs- Option Explicit
- '
- ' 要搜索的字符,这里设置为--,也可以改成其它的字符
- '
- Const constType="--"
- '
- ' 选项,是拷贝还是移动,选项为 "Copy" 或者 "Move"
- ' Const constOption="Move"
- ' Const constOption="Copy"
- '
- '
- '
- '
- Const constOption="Move"
- Dim fileSystemObject, folderInfo, SongList
- Set fileSystemObject = CreateObject("Scripting.FileSystemObject")
- Dim WshShell, strFullName
- Set WshShell = WScript.CreateObject("WScript.Shell")
- ' 获得当前目录
- Set folderInfo = fileSystemObject.GetFolder(WshShell.CurrentDirectory)
- ' 当前目录下所有的文件
- Set SongList = folderInfo.Files
- Dim iPos, strSinger, strSong
- For Each strFullName In SongList
- iPos=InStr(strFullName,constType)
- If iPos>0 Then
- ' 如果文件的类型匹配,则开始下面的操作
- strSinger=Left(strFullName, (iPos-1))
- strSong=Right(strFullName, Len(strFullName)-(iPos-1)-Len(constType))
-
- If ( Not fileSystemObject.FolderExists(strSinger)) Then
- ' 创建以歌手为名的目录
- fileSystemObject.CreateFolder(strSinger)
- End If
- ' 拷贝文件,同时更名
- WScript.Echo "Copying " & strFullName & " to " & strSong
- fileSystemObject.CopyFile strFullName, strSinger & "" & strSong
-
- If (constOption="Move" and fileSystemObject.FileExists(strSinger & "" & strSong)) Then
- ' 如果选项是移动文件,查看目录文件是否存在。如果存在,删除原文件
- WScript.Echo "Deleting " & strFullName
- fileSystemObject.DeleteFile strFullName
- End If
- End If
- Next
复制代码
[ 本帖最后由 guodl 于 2008-10-20 23:27 编辑 ] |
|