hi there
here'a litlle script that i use here at work to move a directory into another folder.
didn't try on system directories, other wise on data directories it works fine.
i would log script action into a .txt file but there's a little problem. Permission denied on the .txt file for error code.
Appreciate your comments.
thanks
here'a litlle script that i use here at work to move a directory into another folder.
didn't try on system directories, other wise on data directories it works fine.
i would log script action into a .txt file but there's a little problem. Permission denied on the .txt file for error code.
Appreciate your comments.
thanks
Code:
'Variable temps
t=Now
'Dossier a créer s'il n'existe pas
strDestination= "C:\FileMaker" & "_" & Day(Now()) & "_" & Month(Now()) & "_" & Year(Now())
'Instance en mémoire
Set fso=CreateObject("Scripting.FileSystemObject")
'Appel de la routine avec arguments
MaRoutine "C:\test", strDestination
'Désactivation instance en mémoire
Set fso=Nothing
sub MaRoutine(repSource, RepDest)
'Constante pour ajout de données dans fichier log sans écrasement fichier existant
Const FOR_APPENDING = 8
'Fichier log définit par l'admin
LogFile= "C:\Backup.log"
'Teste existence du fichier log(s'il existe, rajoute données,cas contraire crée fichier)
If fso.FileExists(LogFile) Then
Set objTextStream = fso.OpenTextFile(LogFile, FOR_APPENDING)
Else
Set objTextStream = fso.CreateTextFile(LogFile)
End IF
Set oFolder = fso.GetFolder(repSource)
if not fso.FolderExists(repDest) then fso.CreateFolder(repDest)
For each oFile in oFolder.Files
S=fso.Buildpath(RepSource,oFile.Name)
D=fso.BuildPath(RepDest, oFile.Name)
On Error Resume next
fso.MoveFile oFile, D
objTextStream.WriteLine "Déplacement à " & t & "-" & oFile & ">>" & D
IF err.Number <> 0 Then
Wscript.Echo "Error Moving File!" & oFile
End IF
Next
For each eFolder in oFolder.SubFolders
S=fso.BuildPath(RepSource, eFolder.Name)
D=fso.BuildPath(RepDest, eFolder.Name)
MaRoutine eFolder, D
fso.DeleteFolder eFolder
Next
Set oFolder = Nothing
End Sub