![]() |
|
|||||||
| ASP & VBScript Forum Need help from a webmaster with ASP or VBScript, you may ask in this forum? |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
hello everyone
Im using a vbs file to move a list of files in a folder to another folder. However I find that if any of the file in the folder is in use(active because used by another program) any file below that is not moved. How can I move all the files that are not in use? any help in the right direction will be appreciated ----------------- this is the code im using Option Explicit Sub MoveFiles(myFileType) Dim FSO, myNewFolder, xM, xD, xY, myFolderName, myPath, myDay, myFolder Set FSO = CreateObject("Scripting.FileSystemObject") myDay = DateAdd("d", -1, Date) xM = MonthName(Month(myDay)) xD = Right("0" & Day(myDay),2) xY = Year(myDay) myPath = FSO.GetParentFolderName(WScript.ScriptFullName) myFolder = FSO.GetFolder(myPath).Name if myFolder = "" then myFolderName = myFolder &"DFM" & "_" & xD & "_" & xM & "_" &xY else myFolderName = myFolder & "_" & xD & "_" & xM & "_" &xY end if myNewFolder = myPath & "\" & myFolderName fso.CreateFolder(myNewFolder) FSO.MoveFile myPath & "\" & "*." & myFileType, myNewFolder &"\" End Sub Call MoveFiles ("mp3") ----------------------------------- thanks ahmed |
|
This ad is part of our Revenue Sharing program |
|
|||
|
See the Modifications
Important ¡¡¡¡¡ >>>>> On error Resume next ------------------------------------------------ Option Explicit Sub MoveFiles(myFileType) On Error Resume Next ' ¡¡¡¡¡IMPORTANT....IMPORTANT...IMPORTANT....¡¡¡ ¡¡ Dim FSO, myNewFolder, xM, xD, xY, myFolderName, myPath, myDay, myFolder Dim ficher, ficherCount, ficher1, GetAnExtension ' NEW VARIABLES Set FSO = CreateObject("Scripting.FileSystemObject") myDay = DateAdd("d", -1, Date) xM = MonthName(Month(myDay)) xD = Right("0" & Day(myDay),2) xY = Year(myDay) myPath = FSO.GetParentFolderName(WScript.ScriptFullName) myFolder = FSO.GetFolder(myPath).Name if myFolder = "" then myFolderName = myFolder &"DFM" & "_" & xD & "_" & xM & "_" &xY else myFolderName = myFolder & "_" & xD & "_" & xM & "_" &xY end if myNewFolder = myPath & "\" & myFolderName fso.CreateFolder(myNewFolder) ''******************* MODIFICATIONS ********************* ' ************* READ FILE AT FILE ********************** Set ficher = fso.GetFolder(myPath ) Set ficherCount = ficher.Files For Each ficher1 in ficherCount GetAnExtension = fso.GetExtensionName(ficher1.name) Err.Clear ' GESTION ERRORS If GetAnExtension = myFileType Then FSO.MoveFile myPath & "\" & ficher1.Name , myNewFolder &"\" End If ' If Err.Number =70 Then MsgBox "This file is in use ..."&Chr(13)& myPath & "\" & ficher1.Name End If Next 'FSO.MoveFile myPath & "\" & "*." & myFileType, myNewFolder &"\" End Sub Call MoveFiles ("mp3") Last edited by Telonius : 10-07-2008 at 02:11 PM. Reason: Mensaje Errors |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| VBscript to check folder & send email if file exists along with path | mahesha_babu | ASP & VBScript Forum | 0 | 06-30-2008 12:39 PM |
| I got something good please check it out.... | Roger123 | All other Scripting/Programming items | 0 | 10-30-2007 02:03 PM |
| Check this out | detoam | Webmasters Lounge/General Chat | 3 | 03-03-2007 01:32 AM |