ปรุงก่อนชิม
Location :
นนทบุรี Thailand

[Profile ทั้งหมด]

ฝากข้อความหลังไมค์
Rss Feed
Smember
ผู้ติดตามบล็อก : 4 คน [?]




New Comments
Group Blog
 
All Blogs
 
Friends' blogs
[Add ปรุงก่อนชิม's blog to your web]
Links
 

 
VBA auto rename all files in the folder

ใช้ excel เป็นตัวเก็บชื่อเพลง sheet 1
column A = ชื่อไฟล์เดิม
column C = ชื่อใหม่

module 1
Sub ChangeFilename_tepakorn()
 Dim M(1, 100) As String
 Dim i As Integer
Const FILEPATH As String = _
"D:ChangeFilename"
Dim strfile As String
Dim filenum As String
strfile = Dir(FILEPATH)

 For i = 1 To 77
         M(0, i) = Cells(i, 1).Value 'exiting file name
         M(1, i) = Cells(i, 3).Value 'new file name
 Next i
 i = 1
Do While strfile <> ""
  Debug.Print strfile
  If strfile = M(0, i) Then
    Name FILEPATH & strfile As FILEPATH & M(1, i) & ".wma"
  End If
  strfile = Dir
 i = i + 1
Loop
End Sub

อีกแบบหนี้ง


Option Explicit
Sub ChangeFilename_ok()
Const FILEPATH As String = _
"C:changefilename"
Dim strfile As String
Dim filenum As String
strfile = Dir(FILEPATH)
Do While strfile <> ""
  Debug.Print strfile
  If Right$(strfile, 3) = "jpg" Then
    filenum = Mid$(strfile, Len(strfile) - 6, 3)
    Name FILEPATH & strfile As FILEPATH & "DSC00" & filenum & ".JPG"
  End If
  strfile = Dir
Loop
End Sub



Create Date : 20 กุมภาพันธ์ 2556
Last Update : 20 กุมภาพันธ์ 2556 14:05:38 น. 1 comments
Counter : 480 Pageviews.

 
Function correctName(t As String) As String
Dim splitbadChar() As String
Dim i, j As Integer
Dim badChar As String
Dim x As String
't = "Thail%an&d"
badChar = "?,#,{,},%,~,&"
splitbadChar = Split(badChar, ",")
For i = 1 To Len(t)
For j = 1 To UBound(splitbadChar)
If Mid(t, i, 1) = splitbadChar(j) Then
x = x & "_"
i = i + 1
End If
Next j
x = x & Mid(t, i, 1)
Next i
'Debug.Print x
correctName = x
End Function


โดย: t IP: 202.91.23.4 วันที่: 31 กรกฎาคม 2557 เวลา:10:52:54 น.  

ชื่อ :
Comment :
  *ใช้ code html ตกแต่งข้อความได้เฉพาะสมาชิก
 
 Pantip.com | PantipMarket.com | Pantown.com | © 2004 BlogGang.com allrights reserved.