¼ÐÃD:
[µo°Ý]
½Ð±Ð¤j¤j¦pªG¥Ø¿ý¦s¦b²¤¹L¤£n½Æ»s¡A¦p¦ó§ï¡AÁÂÁÂ
[¥´¦L¥»¶]
§@ªÌ:
wufonna
®É¶¡:
2019-7-5 20:47
¼ÐÃD:
½Ð±Ð¤j¤j¦pªG¥Ø¿ý¦s¦b²¤¹L¤£n½Æ»s¡A¦p¦ó§ï¡AÁÂÁÂ
¥»©«³Ì«á¥Ñ wufonna ©ó 2019-7-5 20:48 ½s¿è
Option Explicit
Sub Ex()
Dim myPath As String, myFile As String, myname As String, n As Integer, strPath As String
myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô
myFile = "*.JPG"
myname = Dir(myPath & myFile)
Do While myname <> ""
n = n + 1
' Name myPath & myname As myPath & "FS" & Format(n, "00000") & ".jpg"
strPath = myPath & Replace(myname, ".jpg", "")
MkDir strPath
'¿ù»~
'If Len(Dir("c:\test\aaa", vbDirectory)) = 0 Then
' MkDir "c\test\aaa"
'End If
'
myname = Dir
Loop
MsgBox n
End Sub
½Æ»s¥N½X
§@ªÌ:
wufonna
®É¶¡:
2019-7-6 20:14
¥»©«³Ì«á¥Ñ wufonna ©ó 2019-7-6 20:18 ½s¿è
¦^´_
1#
wufonna
§ï³o¼Ë¥i¥H¡A½Ð±Ð¤j¤j
Option Explicit
'§å¦¸§ï¥Ø¿ý
Sub Ex()
Dim myPath As String, myFile As String, myname As String, n As Integer, strPath As String
Dim S() As String, i As Integer, m As Variant
myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô
myFile = "*.JPG"
myname = Dir(myPath & myFile)
i = 0
Do While myname <> ""
n = n + 1
' Name myPath & myname As myPath & "FS" & Format(n, "00000") & ".jpg"
strPath = myPath & Replace(myname, ".jpg", "")
ReDim Preserve S(i)
S(i) = strPath
' Debug.Print S(i)
myname = Dir
i = i + 1
Loop
For Each m In S
' Debug.Print m
If Len(Dir(m, vbDirectory)) = 0 Then
MkDir m
End If
Next
' MsgBox n
End Sub
½Æ»s¥N½X
§@ªÌ:
GBKEE
®É¶¡:
2020-4-26 17:18
¦^´_
2#
wufonna
'**Dir ·|¶Ç¦^²Ä¤@Ó»P_¸ô®|¦WºÙ_¬Û²ÅªºÀɮצWºÙ¡C Yn¨ú±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 ª«¥ó ¸Õ¸Õ
Option Explicit
Sub Ex()
Dim myPath As String, myFile As String, myname As String, n As Variant, strPath As String
Dim AR(), Folder As String
myPath = ThisWorkbook.Path & "\" 'myPath = ThisWorkbook.Path Àɮ׸ô®|
myFile = "*.JPG"
myname = Dir(myPath & myFile, vbDirectory) ' 'Dir ´M§äÀɮ׸ô®|\ *.JPG"ªºÀÉ®×
Do While myname <> ""
strPath = myPath & Replace(myname, ".jpg", "")
With New FileSystemObject '¤Þ¥Î¶µ¥Ø Microsoft Scripting Runtime
On Error Resume Next 'ªí¥Ü·í¤@Ó°õ¦æ¶¥¬q¿ù»~²£¥Í®É¡Aµ{¦¡±±¨î¥ß¨è¨ìµo¥Í¿ù»~³¯z¦¡±µ¤U¥hªº³¯z¦¡¡A¦ÓÄ~Äò°õ¦æ¤U¥h
If .GetFolder(strPath) Is Nothing Then MkDir strPath '**¥[¤J¹Ï¤ù¦WºÙªº¸ê®Æ§¨
On Error GoTo 0 '°±¤î²{¦bµ{§ÇùØ¥ô¦ó¤w±Ò°Êªº¿ù»~³B²zµ{¦¡
End With
myname = Dir
Loop
End Sub
½Æ»s¥N½X
Åwªï¥úÁ{ ³Â»¶®a±Ú°Q½×ª©ª© (http://forum.twbts.com/)