VBS 에서 파일 이름 을 대량으로 바 꾸 고 작업 전에 기 존 파일 을 백업 합 니 다.
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
' NAME:
'
' AUTHOR: Microsoft , Microsoft
' DATE : 2014/7/9
'
' COMMENT: '
'
'==========================================================================
' ,
Const MY_COMPUTER = &H11&
Const WINDOW_HANDLE = 0
Const OPTIONS = 0
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.Namespace(MY_COMPUTER)
Set objFolderItem = objFolder.Self
strPath = objFolderItem.Path
Set objShell = CreateObject("Shell.Application")
Set objFolder = objShell.BrowseForFolder _
(WINDOW_HANDLE, "Select a folder:", OPTIONS, strPath)
If objFolder Is Nothing Then
Wscript.Quit
End If
Set objFolderItem = objFolder.Self
objPath = objFolderItem.Path
'MsgBox objFolderItem.name
'===================================================================
'
' Const WINDOW_HANDLE = 0
' Const OPTIONS = 0
'
' Set objShell = CreateObject("Shell.Application")
' Set objFolder = objShell.BrowseForFolder _
' (WINDOW_HANDLE, "Select a folder:", OPTIONS, "C:\")
'
' If objFolder Is Nothing Then
' Wscript.Quit
' End If
'
' Set objFolderItem = objFolder.Self
' objPath = objFolderItem.Path
'
' MsgBox objPath
'=========================================================================
'
dim file_path,prefix_name,suffix_name,repeat_name,repeat_edit
Dim OneLine,TwoLine,ThreeLine,FourLine,FiveLine
i=0
test = createobject("Scripting.FileSystemObject").GetFile(Wscript.ScriptFullName).ParentFolder.Path
'Wscript.echo test
filepath=test&"\config.ini"
'WScript.Echo filepath
' file_path = "C:\Users\Administrator\Desktop\1\music"'
dst_file_path="C:\"&objFolderItem.name&"_bak"
file_path=objPath
'----- ,
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.getfolder(file_path)
Set fs = folder.files
Set file=fso.OpenTextFile(filepath,1)
'---------------- ,
fso.CopyFolder file_path,dst_file_path,True
'----------------------------------
'
OneLine=file.ReadLine
OneLineStr=Split(OneLine,"=")
OneLineCount=UBound(split(OneLine,"="))
For i1=0 To OneLineCount
'WScript.Echo OneLineStr(i1)
Next
'-------------------------------------
'
TwoLine=file.ReadLine
TwoLineStr=Split(TwoLine,"=")
TwoLineCount=UBound(split(TwoLine,"="))
For i2=0 To TwoLineCount
'WScript.Echo TwoLineStr(i2)
Next
'-------------------------------------------
'
ThreeLine=file.ReadLine
ThreeLineStr=Split(ThreeLine,"=")
ThreeLineCount=UBound(split(ThreeLine,"="))
For i3=0 To ThreeLineCount
'WScript.Echo ThreeLineStr(i3)
Next
'-------------------------------------------
'
FourLine=file.ReadLine
FourLineStr=Split(FourLine,"=")
FourLineCount=UBound(split(FourLine,"="))
For i4=0 To FourLineCount
'WScript.Echo FourLineStr(i4)
Next
'-----------------------------------------
'
FiveLine=file.ReadLine
FiveLineStr=Split(FiveLine,"=")
FiveLineCount=Ubound(split(FiveLine,"="))
For i5=0 To FiveLineCount
'WScript.Echo FiveLineStr(i5)
Next
'---------------------------------------------
'
'Function_Main()
Function Function_Main()
If OneLineStr(1)="true" Then
Function_Prefix_Name()
Elseif OneLineStr(1)="false" Then
Function_Suffix_Name()
Elseif OneLineStr(1)="number" Then
Function_Number_Value()
Elseif OneLineStr(1)="array" Then
Function_MyArrayReName()
Elseif OneLineStr(1)="" Then
WScript.Quit
End If
End Function
'-----------------------------------------
'
Function Function_Prefix_Name()
For Each file in fs
File.Name=TwoLineStr(1)&File.Name
Next
End Function
'--------------------------------------
'
Function Function_Suffix_Name()
For Each file in fs
Name=Mid(file.name,1,instrrev(file.name,".")-1) ' .
Format=Mid(file.name,instrrev(file.name,".")) ' .
file.Name=Name&ThreeLineStr(1)&Format
Next
End Function
'--------------------------------------------
'
Function Function_Number_Value()
For Each file In fs
FourLineStr(1)=FourLineStr(1)+1
file.name=FourLineStr(1)&file.name
Next
End Function
'Function_Suffix_Name()
'--------------------------------------------------
'
Function Function_MyArrayReName()
Const BeforAlarm=" , "
Const AfterAlarm=" , "
Dim MyArray(12)
n=1
y=0
For i=0 To 12
If i=11 Then
MyArray(i)=" "
Elseif i=12 Then
MyArray(i)=" "
Else
MyArray(i)=n&" "
n=n+1
End If
' WScript.Echo MyArray(i)
Next
For Each file In fs
Format=Mid(file.name,instrrev(file.name,"."))
'MsgBox Format
'MsgBox MyArray(y)
If FiveLineStr(1)="before" Then
file.name=MyArray(y)&BeforAlarm&Format
Elseif FiveLineStr(1)="after" Then
file.name=MyArray(y)&AfterAlarm&Format
Else
MsgBox " !",," "
WScript.Quit
End If
y=y+1
'WScript.Echo file.name
Next
End Function
'=======================================================================
' If prefix_name <> "" then'
' For each f in fs
' f.name = prefix_name&f.name
' Next
' End If
'
' if suffix_name <> "" then'
' For each f in fs
' name = Mid(f.name,1,InstrRev(f.name,".")-1)
' format = Mid(f.name,InstrRev(f.name,"."))
' f.name = name & suffix_name & format
' Next
' end If
'
' if repeat_name <> "" then'
' For each f in fs
' On Error Resume Next
' f.name = Replace(f.name,repeat_name,repeat_edit)
' Next
' end If
' '-----
'
' set fso = nothing'
'
' MsgBox(" !")
프로필 필요
config.ini :
statue=
prefix_name=[320kbp]
suffix_name=[ ]
i=20140100
array=
매개 변수 설정 사용 방법:statue=true 시 접두사 추가
statue=false 시 접미사 추가
statue=number 시 질서 있 는 숫자 를 추가 하기 위해 서 입 니 다.
statue=array 호출 배열 함수
statue=빈 값 이 비어 있 을 때 처리 하지 않 고 스 크 립 트 작업 을 종료 합 니 다.
array=before 시 확인 전 으로 설정 합 니 다.
array=after 시 확인 후 로 설정 합 니 다.
array=비 었 을 때 알림 정 보 를 팝 업 하고 스 크 립 트 작업 을 종료 합 니 다.
자,이 글 은 여기까지 소개 하 겠 습 니 다.주로 FileSystem Object 와 mid 함 수 를 사 용 했 습 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
mybatis에서 대량으로 삽입하는 두 가지 방식 (고효율 삽입)MyBatis 소개 MyBatis는 일반 SQL 조회, 저장 프로세스, 고급 매핑을 지원하는 우수한 지구층 프레임워크입니다.MyBatis는 거의 모든 JDBC 코드와 파라미터의 수동 설정과 결과 집합에 대한 검색 봉...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.