API聲明
10多年的臨渭區(qū)網站建設經驗,針對設計、前端、開發(fā)、售后、文案、推廣等六對一服務,響應快,48小時及時工作處理。營銷型網站建設的優(yōu)勢是能夠根據用戶設備顯示端的尺寸不同,自動調整臨渭區(qū)建站的顯示方式,使網站能夠適用不同顯示終端,在瀏覽器中調整網站的寬度,無論在任何一種瀏覽器上瀏覽網站,都能展現優(yōu)雅布局與設計,從而大程度地提升瀏覽體驗。創(chuàng)新互聯公司從事“臨渭區(qū)網站設計”,“臨渭區(qū)網站推廣”以來,每個客戶項目都認真落實執(zhí)行。
Public Declare Function SetFileAttributes Lib "kernel32" Alias "SetFileAttributesA" (ByVal lpFileName As String, ByVal dwFileAttributes As Long) As Long
Public Const FILE_ATTRIBUTE_ARCHIVE = H20
Public Const FILE_ATTRIBUTE_COMPRESSED = H800
Public Const FILE_ATTRIBUTE_DIRECTORY = H10
Public Const FILE_ATTRIBUTE_HIDDEN = H2
Public Const FILE_ATTRIBUTE_NORMAL = H80
Public Const FILE_ATTRIBUTE_READONLY = H1
Public Const FILE_ATTRIBUTE_SYSTEM = H4
Public Const FILE_ATTRIBUTE_TEMPORARY = H100
SetFileAttributes("文件名",FILE_ATTRIBUTE_NORMAL)
批量修改做個循環(huán)就行
假如一個文件為1a.txt一個為1b.txt呢,該怎么改,你總得說清楚。改了第一個就改不了第二個了。
====================================
'給你一個代碼,不用控件的,你沒說遇到改后文件名一樣怎么辦,所以我的做法是文件名一樣就跳過,如果不含數字的也跳過。
'*************************************************************************
'**模 塊 名:Form1
'**說 明:廈門大學化學系 版權所有2009 - 2010(C)
'**創(chuàng) 建 人:吳志明(寒江雪)
'**日 期:2009-03-10 19:15:18
'**聯系方式:verywzm@163.com
'**主 頁:
'**描 述:
'**版 本:V1.0.0
'*************************************************************************
Private Sub Command1_Click()
On Error GoTo ToExit '打開錯誤陷阱
'------------------------------------------------
Dim FileName, NewFileName As String
FileName = Dir("C:\temp\", vbReadOnly + vbHidden + vbSystem + vbNormal)
Do While Not FileName = ""
NewFileName = NUM(FileName)
If NewFileName "" And Left(NewFileName, 1) "." Then
Name "C:\temp\" FileName As "c:\temp\" NewFileName
End If
FileName = Dir()
Loop
'------------------------------------------------
Exit Sub
'----------------
ToExit:
Resume Next
End Sub
Private Function NUM(ByVal strTest As String) As String
Dim strExtend As String
Dim strRet As String
Dim bytArray() As Byte
Dim intcount As Integer
If Len(strTest) 3 Then
If Mid(strTest, Len(strTest) - 3, 1) = "." Then strExtend = Right(strTest, 4)
End If
bytArray = strTest
For intcount = 0 To UBound(bytArray)
If bytArray(intcount) = Asc("0") And bytArray(intcount) = Asc("9") Then
strRet = strRet + Chr(bytArray(intcount))
End If
Next
strRet = strRet + strExtend
NUM = strRet
End Function
==================================
目錄要任意的話把代碼中"C:\temp\"換掉就好了嘛,比如換成text1.text
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fd = FSO.GetFolder("E:\") '在這句中更改文件夾
For Each f In fd.Files
If LCase(Right(f.Name, 4)) = ".mp3" Then Name f.Path As f.ParentFolder "\" Right(f.Name, Len(f.Name) - 3)
Next
Name 語句
重新命名一個文件、目錄、或文件夾。
語法
Name oldpathname As newpathname
oldpathname --- 原文件名
newpathname --- 新文件名
例如:
Name "閭撳皬騫蟲椂浠e叏25绔_doc" As "閭撳皬騫蟲椂浠e叏25绔.doc"
方法一:Dim fpPrivate Sub refilename(folderspec)Dim fs, f, f1, fc, sm, hzSet fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)Set fc = f.FilesFor Each f1 In fc
hz = Mid(f1.Name, InStrRev(f1.Name, "."))
Name f1 As fp "20101007-" hz
NextMsgBox "修改完成"End SubPrivate Sub Command1_Click()fp = "E:\emot\xhh\"'這里設置文件夾路徑,根的需要來修改
If Right(fp, 1) "\" And Right(fp, 1) "/"
Then fp = fp "\"Call refilename(fp)
’調用上面的自定義函數,改名End Sub........
方法二: '將f:\123\文件下的txt文件改名
Dim files() As String '用于貯存文件名
Dim length As Integer = 0 'files數組長度
Dim fileName As String = Dir$("f:\123\*.txt") '得到第一個.txt文件的文件名
'Dim g As Graphics = Me.CreateGraphics
Do While fileName ""
'g.DrawString(length, Font, Brushes.Red, length * 10, length * 10)
ReDim Preserve files(length)
files(length) = fileName
length = files.Length
fileName = Dir$() '得到下一個.txt文件的文件名
Loop
For i = 0 To length - 1
Dim oldfileName As String = "f:\123\" + files(i)
Dim newfileName As String = "f:\123\" + "20101007_"+ files(i)
Rename(oldfileName, newfileName) '修改文件名
Next