It seems I have some problems with the hard drive itself. It's acting strange. Some files appear duplicates and I delete the duplicates. A few minutes later i refresh the directory and they are back. Refresh again and they are gone. Files are visible on one computer but not the other. I will try to trouble shoot it and see where what the issue is. Thanks for all the help so far it may be more than one problem acting together.
I have used this code to rename and move files from one location to another on my network drive.
The video files are named 00001, 00002 etc.. and since the counter resets i need to rename the files to something that can work on a harddrive.
So all files are renamed to <date> <time>.MTS
This code used to work but now it just stoped working by some reason.
Sub MoveFiles()
Dim r As Integer
r = 2 'first line of files
Set objFSO = CreateObject("Scripting.FileSystemObject")
Do Until IsEmpty(Cells(r, "A")) Or IsEmpty(Cells(r, "B"))
dirPath = Cells(r, "C") + "\" + Cells(r, "B")
If objFSO.FileExists(dirPath) Then
' file exist output error message
MsgBox ("Filen finns redan!!! " + Cells(r, "A") + " " + Cells(r, "B"))
Else
FromName = ActiveWorkbook.Path + "\" + Cells(r, "A")
ToName = Cells(r, "C") + "\" + Cells(r, "B")
' none of the methods below work.
Name FromName As ToName
Name ActiveWorkbook.Path + "\" + Cells(r, "A") As Cells(r, "C") + "\" + Cells(r, "B")
End If
r = r + 1
Loop
End Sub
Since the code does not create the error message that the ToName exsists then it's not a "duplicate" issue.
If I run the following code
If objFSO.FileExists(ActiveWorkbook.Path + "\" + Cells(r, "A")) Then
MsgBox "test"
End If
I get the message box, which means that FromName file exsists.
So in short the file exsists and the filename that it will become does not exsist. Also the paths (directories) exsist as they are created in a earlier sub(). And I have double checked it. So what can be the problem?
I'm completly lost here.