Si le dossier ALPHA n'existe pas en C:\ le créer.
Puis, créer une variable Mavar qui donne Mavar = "date du jour et heure"
au format jj.mmmm.aaaa.hh.mm
Copier un fichier "toto" qui se trouve dans C:\BETA\toto, puis lui
coller la variable afin qu'il devienne totojj.mmmm.aaaa.hh.mm, puis le
coller dans le dossier ALPHA
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
at
Alain Lebayle a présenté l'énoncé suivant :
Bonjour,
Je souhaite écrire un code en VBS, qui dit ceci :
Si le dossier ALPHA n'existe pas en C: le créer. Puis, créer une variable Mavar qui donne Mavar = "date du jour et heure" au format jj.mmmm.aaaa.hh.mm Copier un fichier "toto" qui se trouve dans C:BETAtoto, puis lui coller la variable afin qu'il devienne totojj.mmmm.aaaa.hh.mm, puis le coller dans le dossier ALPHA
Je vous remercie beaucoup Alain
Ce n'est pas le bon groupe.
Voici le code:
Dim sp dim X,temp,jma
X = MakeDir("c:alpha")
temp = FormatDateTime(Now,1)
sp = Split(temp," ")
jma = sp(1) + "." + sp(2) + "." + sp(3) + "."
temp = FormatDateTime(Now,3)
sp = Split(temp,":")
jma = jma + sp(0) + "." + sp(1)
move "c:betatoto","c:alphatoto" & jma
Function MakeDir (strPath) Dim strParentPath, objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next strParentPath = objFSO.GetParentFolderName(strPath)
If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder strPath On Error Goto 0 MakeDir = objFSO.FolderExists(strPath) End Function
function copy(old_,new_)
Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.CopyFile old_, new_,TRUE
end function
Function move(old_,new_)
Dim fso Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile old_, new_
End Function ' ' '
A+
Alain Lebayle a présenté l'énoncé suivant :
Bonjour,
Je souhaite écrire un code en VBS, qui dit ceci :
Si le dossier ALPHA n'existe pas en C: le créer.
Puis, créer une variable Mavar qui donne Mavar = "date du jour et heure" au
format jj.mmmm.aaaa.hh.mm
Copier un fichier "toto" qui se trouve dans C:BETAtoto, puis lui coller la
variable afin qu'il devienne totojj.mmmm.aaaa.hh.mm, puis le coller dans le
dossier ALPHA
Je vous remercie beaucoup
Alain
Ce n'est pas le bon groupe.
Voici le code:
Dim sp
dim X,temp,jma
X = MakeDir("c:alpha")
temp = FormatDateTime(Now,1)
sp = Split(temp," ")
jma = sp(1) + "." + sp(2) + "." + sp(3) + "."
temp = FormatDateTime(Now,3)
sp = Split(temp,":")
jma = jma + sp(0) + "." + sp(1)
move "c:betatoto","c:alphatoto" & jma
Function MakeDir (strPath)
Dim strParentPath, objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
On Error Resume Next
strParentPath = objFSO.GetParentFolderName(strPath)
If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath
If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder strPath
On Error Goto 0
MakeDir = objFSO.FolderExists(strPath)
End Function
function copy(old_,new_)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile old_, new_,TRUE
end function
Function move(old_,new_)
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Si le dossier ALPHA n'existe pas en C: le créer. Puis, créer une variable Mavar qui donne Mavar = "date du jour et heure" au format jj.mmmm.aaaa.hh.mm Copier un fichier "toto" qui se trouve dans C:BETAtoto, puis lui coller la variable afin qu'il devienne totojj.mmmm.aaaa.hh.mm, puis le coller dans le dossier ALPHA
Je vous remercie beaucoup Alain
Ce n'est pas le bon groupe.
Voici le code:
Dim sp dim X,temp,jma
X = MakeDir("c:alpha")
temp = FormatDateTime(Now,1)
sp = Split(temp," ")
jma = sp(1) + "." + sp(2) + "." + sp(3) + "."
temp = FormatDateTime(Now,3)
sp = Split(temp,":")
jma = jma + sp(0) + "." + sp(1)
move "c:betatoto","c:alphatoto" & jma
Function MakeDir (strPath) Dim strParentPath, objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") On Error Resume Next strParentPath = objFSO.GetParentFolderName(strPath)
If Not objFSO.FolderExists(strParentPath) Then MakeDir strParentPath If Not objFSO.FolderExists(strPath) Then objFSO.CreateFolder strPath On Error Goto 0 MakeDir = objFSO.FolderExists(strPath) End Function
function copy(old_,new_)
Dim fso Set fso = CreateObject("Scripting.FileSystemObject") fso.CopyFile old_, new_,TRUE
end function
Function move(old_,new_)
Dim fso Set fso = CreateObject("Scripting.FileSystemObject")
fso.MoveFile old_, new_
End Function ' ' '
A+
at
Après mûre réflexion, at a écrit :
move "c:betatoto","c:alphatoto" & jma
Et à remplacer par
copy "c:betatoto","c:alphatoto" & jma
Car "move" déplace le fichier. J'avais prévu les deux situations.
Après mûre réflexion, at a écrit :
move "c:betatoto","c:alphatoto" & jma
Et à remplacer par
copy "c:betatoto","c:alphatoto" & jma
Car "move" déplace le fichier. J'avais prévu les deux situations.