关于复制并重命名问题(已解决)
本帖最后由 shenrenba 于 2010-10-11 09:48 编辑下面代码中我就是把歌重新复制并重命名文件一旦多 则大部分都是命名不全(一般都是没后缀和歌曲名)该如何解决 还是我代码有问题?#include <File.au3>
$path = @UserProfileDir & "\Local Settings\Temporary Internet Files"
$search = findfile($path)
Func findfile($path)
$aFileList = _FileListToArray($path)
If Not @error Then
For $i = 1 To $aFileList
findfile($path & '\' & $aFileList[$i])
If StringRight($path & '\' & $aFileList[$i], 4) = '.mp3' Then
$mp3info = _GetMp3info($path & '\' & $aFileList[$i])
If Not @error Then
$mp3people = StringRegExpReplace($mp3info, '\s+', '')
$mp3name = StringRegExpReplace($mp3info, '\s+', '')
;FileMove($path & '\' & $aFileList[$i], "D:\123\" & $mp3people & "-" & $mp3name & ".mp3", 9)
FileCopy($path & '\' & $aFileList[$i], "D:\123\" & $mp3people & "-" & $mp3name & ".mp3", 9)
Else
;FileMove($path & '\' & $aFileList[$i], "D:\123\", 9)
FileCopy($path & '\' & $aFileList[$i], "D:\123\", 9)
EndIf
EndIf
Next
EndIf
EndFunc ;==>findfile
Func _GetMp3info($nFile)
$hFile = FileOpen($nFile, 0)
If $hFile = -1 Then
SetError(1)
Return ""
Else
FileSetPos($hFile, -128, 2)
$bBuffer = FileRead($hFile, 128)
If BinaryToString(BinaryMid($bBuffer, 1, 3)) = "TAG" Then
Local $TMPARRAY
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 4, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 34, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 64, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 94, 4))
Return $TMPARRAY
Else
SetError(2)
Return ""
EndIf
EndIf
FileClose($hFile)
EndFunc ;==>_GetMp3info 看似字符串,其实不是。
#include <File.au3>
$path = @UserProfileDir & "\Local Settings\Temporary Internet Files"
$search = findfile($path)
Func findfile($path)
$aFileList = _FileListToArray($path)
If Not @error Then
For $i = 1 To $aFileList
findfile($path & '\' & $aFileList[$i])
If StringRight($path & '\' & $aFileList[$i], 4) = '.mp3' Then
$mp3info = _GetMp3info($path & '\' & $aFileList[$i])
;~ If IsArray($mp3info) Then MsgBox(0,0,String($mp3info)&string($mp3info))
If Not @error Then
$mp3people = StringRegExpReplace(String($mp3info), '\s+', '')
$mp3name = StringRegExpReplace(String($mp3info), '\s+', '')
;FileMove($path & '\' & $aFileList[$i], "D:\123\" & $mp3people & "-" & $mp3name & ".mp3", 9)
FileCopy($path & '\' & $aFileList[$i], "D:\123\" & $mp3people & "-" & $mp3name & ".mp3", 9)
Else
;FileMove($path & '\' & $aFileList[$i], "D:\123\", 9)
FileCopy($path & '\' & $aFileList[$i], "D:\123\", 9)
EndIf
EndIf
Next
EndIf
EndFunc ;==>findfile
Func _GetMp3info($nFile)
$hFile = FileOpen($nFile, 0)
If $hFile = -1 Then
SetError(1)
Return ""
Else
FileSetPos($hFile, -128, 2)
$bBuffer = FileRead($hFile, 128)
If BinaryToString(BinaryMid($bBuffer, 1, 3)) = "TAG" Then
Local $TMPARRAY
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 4, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 34, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 64, 30))
$TMPARRAY = BinaryToString(BinaryMid($bBuffer, 94, 4))
Return $TMPARRAY
Else
SetError(2)
Return ""
EndIf
EndIf
FileClose($hFile)
EndFunc ;==>_GetMp3info
页:
[1]