VBS - Transfer oldest file

Good Afternoon :slightly_smiling_face:

I’m trying to "Execute VBScritpt that moves the oldest file from a folder to another.


Dim colFiles 
Dim strStartFolder 
Dim strDestinationfolder 
Dim oOldestFile 
Dim oFile 
Dim oFSO 
strStartFolder = "Source"
Do While I=0
Set oFSO = CreateObject("Scripting.FileSystemObject") 
Set colFiles = oFSO.GetFolder(strStartFolder).Files 
If colFiles.Count <= 1 Then 
End If 
For Each oFile In colFiles 
   If Not IsObject(oOldestFile) Then 
       Set oOldestFile = oFile 
       If oFile.DateLastModified < oOl
[Invoke VBScript.xaml|attachment](upload://A13aRwD3SydHc5KpYu9jKz6GDAk.xaml) (4.4 KB)
destFile.DateLastModified Then 
           Set oOldestFile = oFile 
       End If 
   End If 
Do While i=0
oOldestFile.Move strDestinationfolder & "\" & oOldestFile.Name 
Wscript.Sleep (2000)
Loop`Preformatted text`

For now, it moves each file every two minutes starting with the oldest.
But the idea is only to move files when the robot is compiled.

Right now is not working but also I’m not receiving any error
Can someone take a look at my XML file and advise?

Thank you

@Andre_Vieira - have you tried the code which I shared the other day? Was it not working?

1 Like

Hello Dear Friend!! :grin:

Actually, I did solve this problem with it just now. I used your code to reach the same result. Once again. Thank you :smiley:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.