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

[µo°Ý] ½Ð±Ð¤j¤j¦pªG¥Ø¿ý¦s¦b²¤¹L¤£­n½Æ»s¡A¦p¦ó§ï¡AÁÂÁÂ

[µo°Ý] ½Ð±Ð¤j¤j¦pªG¥Ø¿ý¦s¦b²¤¹L¤£­n½Æ»s¡A¦p¦ó§ï¡AÁÂÁÂ

¥»©«³Ì«á¥Ñ wufonna ©ó 2019-7-5 20:48 ½s¿è
  1. Option Explicit
  2. Sub Ex()
  3.     Dim myPath As String, myFile As String, myname As String, n As Integer, strPath As String
  4.     myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô
  5.     myFile = "*.JPG"
  6.     myname = Dir(myPath & myFile)

  7.     Do While myname <> ""
  8.         n = n + 1
  9. '       Name myPath & myname As myPath & "FS" & Format(n, "00000") & ".jpg"
  10. strPath = myPath & Replace(myname, ".jpg", "")



  11.    MkDir strPath
  12. '¿ù»~
  13. 'If Len(Dir("c:\test\aaa", vbDirectory)) = 0 Then
  14. ' MkDir "c\test\aaa"
  15. 'End If
  16. '
  17.         myname = Dir
  18.     Loop
  19.     MsgBox n
  20. End Sub
½Æ»s¥N½X

mkdirtest.zip (271.2 KB)

¥»©«³Ì«á¥Ñ wufonna ©ó 2019-7-6 20:18 ½s¿è

¦^´_ 1# wufonna
§ï³o¼Ë¥i¥H¡A½Ð±Ð¤j¤j
  1. Option Explicit
  2. '§å¦¸§ï¥Ø¿ý
  3. Sub Ex()
  4.     Dim myPath As String, myFile As String, myname As String, n As Integer, strPath As String
  5.     Dim S() As String, i As Integer, m As Variant
  6.     myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô
  7.     myFile = "*.JPG"
  8.     myname = Dir(myPath & myFile)
  9.     i = 0

  10.     Do While myname <> ""
  11.         n = n + 1
  12. '       Name myPath & myname As myPath & "FS" & Format(n, "00000") & ".jpg"
  13. strPath = myPath & Replace(myname, ".jpg", "")

  14.     ReDim Preserve S(i)
  15.     S(i) = strPath
  16.   ' Debug.Print S(i)
  17.          myname = Dir

  18. i = i + 1
  19.     Loop


  20.     For Each m In S
  21. '    Debug.Print m

  22.      If Len(Dir(m, vbDirectory)) = 0 Then
  23.       MkDir m
  24.      End If
  25.     Next
  26.    
  27.    ' MsgBox n
  28. End Sub
½Æ»s¥N½X

TOP

¦^´_ 2# wufonna
'**Dir ·|¶Ç¦^²Ä¤@­Ó»P_¸ô®|¦WºÙ_¬Û²ÅªºÀɮצWºÙ¡C ­Y­n¨ú±o¥ô¦ó»P_¸ô®|¦WºÙ_¬Û²Åªº¨ä¥LÀɮצWºÙ¡A½Ð¦A¦¸©I¥s¤£§t¤Þ¼Æªº Dir
§AªþÀɪºµ{¦¡½X¦³ª¼ÂI    If Dir(strPath, vbDirectory) = "" Then MkDir strPath
'**¤W¦¡µ{¦¡½X¦A¦¸¨Ï¥Î Dir(strPath, vbDirectory)   ¾É­P   myname = Dir ¶Ç¦^ªÅ¦Û¦r¦ê

§A³oµ{¦¡½X¥i¥Hªº
¤]¥i¥ÎFileSystemObject ª«¥ó ¸Õ¸Õ
  1. Option Explicit
  2. Sub Ex()
  3.     Dim myPath As String, myFile As String, myname As String, n As Variant, strPath As String
  4.     Dim AR(), Folder As String
  5.     myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô®|
  6.     myFile = "*.JPG"
  7.     myname = Dir(myPath & myFile, vbDirectory) ' 'Dir ´M§äÀɮ׸ô®|\ *.JPG"ªºÀÉ®×
  8.     Do While myname <> ""
  9.         strPath = myPath & Replace(myname, ".jpg", "")
  10.         With New FileSystemObject  '¤Þ¥Î¶µ¥Ø Microsoft Scripting Runtime
  11.             On Error Resume Next    'ªí¥Ü·í¤@­Ó°õ¦æ¶¥¬q¿ù»~²£¥Í®É¡Aµ{¦¡±±¨î¥ß¨è¨ìµo¥Í¿ù»~³¯­z¦¡±µ¤U¥hªº³¯­z¦¡¡A¦ÓÄ~Äò°õ¦æ¤U¥h
  12.             If .GetFolder(strPath) Is Nothing Then MkDir strPath                                 '**¥[¤J¹Ï¤ù¦WºÙªº¸ê®Æ§¨
  13.             On Error GoTo 0                '°±¤î²{¦bµ{§ÇùØ¥ô¦ó¤w±Ò°Êªº¿ù»~³B²zµ{¦¡
  14.         End With
  15.         myname = Dir
  16.     Loop
  17. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

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