C
canvas
Hello,
A question.
I have many directories and files in them. I wrote a vba script to rename
the files in the directories.
The files must have the name of the directory where it's in:
If the file: test.ape is in the directory 12 then the files must be:
12_test.ape.
The script works but the strange thing is that if the filenames are changed
the dir command sees the new
name and renames it again like 12_test12_test_12_test.ape.
Is there a way to avoid this???/
Sub autoopen()
Dim strNewName As String
Dim strOldName As String
Dim pad As String, map As String
Dim test As Integer
Dim x As Integer
pad = ActiveDocument.Path
test = MsgBox("doorgaan?", vbYesNo)
If test = vbNo Then
Exit Sub
End If
For x = 1 To 300
strOldName = Dir(pad & "\" & x & "\*.ape")
Do While Len(strOldName) > 0
strNewName = x & "_" & strOldName
Name pad & "\" & x & "\" & strOldName As pad & "\" & x & "\" &
strNewName
strOldName = Dir()
Loop
Next x
MsgBox "ready"
Application.Quit
End Sub
Thanks a lot
A question.
I have many directories and files in them. I wrote a vba script to rename
the files in the directories.
The files must have the name of the directory where it's in:
If the file: test.ape is in the directory 12 then the files must be:
12_test.ape.
The script works but the strange thing is that if the filenames are changed
the dir command sees the new
name and renames it again like 12_test12_test_12_test.ape.
Is there a way to avoid this???/
Sub autoopen()
Dim strNewName As String
Dim strOldName As String
Dim pad As String, map As String
Dim test As Integer
Dim x As Integer
pad = ActiveDocument.Path
test = MsgBox("doorgaan?", vbYesNo)
If test = vbNo Then
Exit Sub
End If
For x = 1 To 300
strOldName = Dir(pad & "\" & x & "\*.ape")
Do While Len(strOldName) > 0
strNewName = x & "_" & strOldName
Name pad & "\" & x & "\" & strOldName As pad & "\" & x & "\" &
strNewName
strOldName = Dir()
Loop
Next x
MsgBox "ready"
Application.Quit
End Sub
Thanks a lot