ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ÀɮצWºÙ¦Û°ÊÅܧó

[µo°Ý] ÀɮצWºÙ¦Û°ÊÅܧó

DEAR ALL ¤j¤j-
1.VBA¦³µL¿ìªk°w¹ï C:\AAA ¸ê®Æ§¨¤ºALLÀÉ®×.¨ä¦WºÙ²Å¦X±ø¥ó¤§ÀɮצWºÙ¦Û°ÊÅܧó
1.1 Åܧó¦WºÙ¤@:
     ±ø¥ó: ÀɮצWºÙtest1¶}ÀY AND ²Ä7½X=1 ®É.¨ä²Ä7½X§ï¬°2
     µ²ªG: ¨Ò-¸ê®Æ§¨¤ºªºtest1-1-01.txt¡Btest1-1-02.txt©Mtest1-1-03.txtªº²Ä¤C¦ì¤¸1§ï¬°2¡AÅܦ¨test1-2-01¡Btest1-2-02©Mtest1-2-03¡C
1.2Åܧó¦WºÙ¤G:
±ø¥ó:ÀɮצWºÙtest1¶}ÀY AND ²Ä8½X=»s ®É.¨ä²Ä8½X¡¨»s¡¨¦r¼Ë§R°£
µ²ªG:¨Ò-¸ê®Æ§¨¤ºªºtest1-½Æ»s1.txt¡Btest1-½Æ»s.txt 2©Mtest1-½Æ»s3.txt ¤º²Ä¤K½X¡¨»s¡¨¦r¼Ë§R°£
2.·Ð¤£§[½ç±Ð   THANKS
ù

¤£ª¾·|§_­«¦W¡A°Nºt¥Ü¤@¤U¡C
Sub zz()
Dim p$, f
p = "Z:\AAA"
f = Dir(p & "\" & "test*")
Do While f <> ""
    If Mid(f, 7, 1) = 1 Then Debug.Print Mid(f, 1, 6) & 2 & Mid(f, 8)
    If Mid(f, 8, 1) = "»s" Then Debug.Print Mid(f, 1, 7) & 2 & Mid(f, 9)
f = Dir
Loop
End Sub

TOP

DEAR   SIR
µLªkÅܧó¦WºÙ.ÁÙ¬OÁ©Ô
ù

TOP

¦^´_ 1# rouber590324

¥i¥H¦Û¤v«ü©w¨Ó·½Àɮ׸ê®Æ§¨

³Ì«á·|§â§ó¦W«áªºÀɮשñ¨ìRename¸ê®Æ§¨

¸Õ¸Õªþ¥ó§a !
  1. Option Explicit

  2. Private Sub File_Rename_Click()

  3.     Dim i As Integer
  4.     Dim FolderPath, original_file, rename_file As String
  5.    
  6. '    On Error Resume Next
  7.    
  8.     '¿ï¾Ü¨Ó·½Àɮ׸ê®Æ§¨
  9.     With Application.FileDialog(msoFileDialogFolderPicker)

  10.         .Title = "¿ï¾ÜÀɮרӷ½¸ê®Æ§¨"
  11.         .Show
  12.         FolderPath = .SelectedItems(1) & "\"
  13.         Debug.Print FolderPath
  14.    
  15.     End With

  16.     '²MªÅEXCEL
  17.     If Worksheets(1).Range("A2") <> "" Then Worksheets(1).Range("A2:B" & Worksheets(1).Range("A65536").End(xlUp).Row) = ""
  18.    
  19.     '§PÂ_¬O§_¦³¿ï¾Ü¨Ó·½¸ê®Æ§¨
  20.     If FolderPath <> "" Then
  21.         
  22.         original_file = Dir(FolderPath & "*.*")
  23.         i = 1
  24.         Do Until original_file = ""
  25.             i = i + 1
  26.             Worksheets(1).Cells(i, 1) = original_file
  27.             original_file = Dir
  28.         Loop


  29.         '¸ê®Æ§¨¤£¦s¦b«h·s«Ø
  30.         If Dir(FolderPath & "\Rename", vbDirectory) = "" Then MkDir FolderPath & "\Rename"

  31.         For i = 2 To Worksheets(1).Range("A65536").End(xlUp).Row

  32.             '­×§ïÀɦW
  33.             If Left(Worksheets(1).Range("A" & i), 5) = "test1" And Mid(Worksheets(1).Range("A" & i), 7, 1) = "1" Then
  34.             
  35.                 rename_file = Mid(Worksheets(1).Range("A" & i), 1, 6) & "2" & Mid((Worksheets(1).Range("A" & i)), 8)
  36.                
  37.                 Worksheets(1).Range("B" & i) = rename_file
  38.                
  39.                 Call FileSystem.FileCopy(FolderPath & Worksheets(1).Range("A" & i), FolderPath & "\Rename\" & rename_file)
  40.                
  41.             ElseIf Left(Worksheets(1).Range("A" & i), 5) = "test1" And Mid(Worksheets(1).Range("A" & i), 8, 1) = "»s" Then

  42.                 rename_file = Mid(Worksheets(1).Range("A" & i), 1, 7) & Mid(Worksheets(1).Range("A" & i), 9)
  43.                
  44.                 Worksheets(1).Range("B" & i) = rename_file
  45.                
  46.                 Call FileSystem.FileCopy(FolderPath & Worksheets(1).Range("A" & i), FolderPath & "\Rename\" & rename_file)
  47.                
  48.             End If

  49.         Next

  50.         MsgBox "§ó¦W§¹¦¨"
  51.    
  52.         '¶}±Òµ²ªG¸ô®|
  53.         ActiveWorkbook.FollowHyperlink Address:=FolderPath + "\Rename\", NewWindow:=True
  54.    
  55.     End If

  56. End Sub
½Æ»s¥N½X
ÀÉ®×­«·s©R¦W.zip (15.62 KB)
¥Î¥\¨ì¥@¬É¥½¤é¨º¤@¤Ñ¡ã¡ã¡ã

TOP

Sub TEST()
Dim P$, F$, Nm$
P = "C:\AAA\"
Do
  If F = "" Then F = Dir(P & "test1-*.txt") Else F = Dir()
  If F = "" Then Exit Sub
  Nm = ""
  If Mid(F, 6, 3) = "-1-" Then Nm = Left(F, 6) & 2 & Mid(F, 8)
  If Mid(F, 8, 1) = "»s" Then Nm = Left(F, 7) & Mid(F, 9)
  If Nm <> "" Then Name P & F As P & Nm
Loop
End Sub

TOP

dear   li_hsien  »P  ­ã´£³¡ªL  ¤j¤j-
thanks*10000  100%²Å¦X»Ý¨D
ù

TOP

DEAR ALL ¤j¤j
1.½Ð±Ð°ÝÃD¦p¤U-
   C:\AAA\¤U²Å¦X§ï¦WªºÀɮקï¦W«á©ñ¨ìRename¸ê®Æ§¨¤º,µM«á²¾°£C:\AAA\§ï¦W¦¨¥\ªºÀÉ®×,
   ¦ÓC:\AAA\¥¼¦¨¥\©Î«D¦¹ÅÞ¿è©Êªº¤ºªºÀÉ®×Ä~Äò«O¯d¡C
2.½Ð±Ð¦p¦ó­×§ïµ{¦¡.·Ð¤£§[½ç±Ð  THANKS*10000
ù

TOP

        ÀR«ä¦Û¦b : ·R¤£¬O­n¨D¹ï¤è¡A¦Ó¬O­n¥Ñ¦Û¨­ªº¥I¥X¡C
ªð¦^¦Cªí ¤W¤@¥DÃD