copie en VBS avec des Extensions connues ou des Jokers
2 réponses
---DGI 972---
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en
connaissant l'extension d'un fichier et/ou le début d'un fichier.
L'équivalent de copy c:\documents\*.doc c:\test\.
ou copy c:\documents\Lettre????.* c:\test\
sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1,
false).
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
Jacques Barathon [MS]
CopyFile, extrait du Platform SDK:
*** Copies one or more files from one location to another. object.CopyFile ( source, destination[, overwrite] ) Arguments object Required. The object is always the name of a FileSystemObject. source Required. Character string file specification, which can include wildcard characters, for one or more files to be copied. destination Required. Character string destination where the file or files from source are to be copied. Wildcard characters are not allowed. overwrite Optional. Boolean value that indicates if existing files are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite. Remarks Wildcard characters can only be used in the last path component of the source argument. For example, you can use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocumentsletters*.doc", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder" But you cannot use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocuments*R1???97.xls", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder" If source contains wildcard characters or destination ends with a path separator (), it is assumed that destination is an existing folder in which to copy matching files. Otherwise, destination is assumed to be the name of a file to create. In either case, three things can happen when an individual file is copied.
a.. If destination does not exist, source gets copied. This is the usual case. b.. If destination is an existing file, an error occurs if overwrite is false. Otherwise, an attempt is made to copy source over the existing file. c.. If destination is a directory, an error occurs. An error also occurs if a source using wildcard characters doesn't match any files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message news:%
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en connaissant l'extension d'un fichier et/ou le début d'un fichier. L'équivalent de copy c:documents*.doc c:test. ou copy c:documentsLettre????.* c:test sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1, false).
merci
CopyFile, extrait du Platform SDK:
***
Copies one or more files from one location to another.
object.CopyFile ( source, destination[, overwrite] )
Arguments
object
Required. The object is always the name of a FileSystemObject.
source
Required. Character string file specification, which can include wildcard
characters, for one or more files to be copied.
destination
Required. Character string destination where the file or files from source
are to be copied. Wildcard characters are not allowed.
overwrite
Optional. Boolean value that indicates if existing files are to be
overwritten. If true, files are overwritten; if false, they are not. The
default is true. Note that CopyFile will fail if destination has the
read-only attribute set, regardless of the value of overwrite.
Remarks
Wildcard characters can only be used in the last path component of the
source argument. For example, you can use:
[JScript]
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile ("c:\mydocuments\letters\*.doc", "c:\tempfolder\")
[VBScript]
FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder"
But you cannot use:
[JScript]
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile ("c:\mydocuments\*\R1???97.xls", "c:\tempfolder")
[VBScript]
FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder"
If source contains wildcard characters or destination ends with a path
separator (), it is assumed that destination is an existing folder in which
to copy matching files. Otherwise, destination is assumed to be the name of
a file to create. In either case, three things can happen when an individual
file is copied.
a.. If destination does not exist, source gets copied. This is the usual
case.
b.. If destination is an existing file, an error occurs if overwrite is
false. Otherwise, an attempt is made to copy source over the existing file.
c.. If destination is a directory, an error occurs.
An error also occurs if a source using wildcard characters doesn't match any
files. The CopyFile method stops on the first error it encounters. No
attempt is made to roll back or undo any changes made before an error
occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message
news:%238boiZOyEHA.1524@TK2MSFTNGP09.phx.gbl...
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en
connaissant l'extension d'un fichier et/ou le début d'un fichier.
L'équivalent de copy c:documents*.doc c:test.
ou copy c:documentsLettre????.* c:test
sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1,
false).
*** Copies one or more files from one location to another. object.CopyFile ( source, destination[, overwrite] ) Arguments object Required. The object is always the name of a FileSystemObject. source Required. Character string file specification, which can include wildcard characters, for one or more files to be copied. destination Required. Character string destination where the file or files from source are to be copied. Wildcard characters are not allowed. overwrite Optional. Boolean value that indicates if existing files are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite. Remarks Wildcard characters can only be used in the last path component of the source argument. For example, you can use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocumentsletters*.doc", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder" But you cannot use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocuments*R1???97.xls", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder" If source contains wildcard characters or destination ends with a path separator (), it is assumed that destination is an existing folder in which to copy matching files. Otherwise, destination is assumed to be the name of a file to create. In either case, three things can happen when an individual file is copied.
a.. If destination does not exist, source gets copied. This is the usual case. b.. If destination is an existing file, an error occurs if overwrite is false. Otherwise, an attempt is made to copy source over the existing file. c.. If destination is a directory, an error occurs. An error also occurs if a source using wildcard characters doesn't match any files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message news:%
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en connaissant l'extension d'un fichier et/ou le début d'un fichier. L'équivalent de copy c:documents*.doc c:test. ou copy c:documentsLettre????.* c:test sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1, false).
merci
---DGI972---
merci, je vais essayer tout de suite.
"Jacques Barathon [MS]" a écrit dans le message de news:
CopyFile, extrait du Platform SDK:
*** Copies one or more files from one location to another. object.CopyFile ( source, destination[, overwrite] ) Arguments object Required. The object is always the name of a FileSystemObject. source Required. Character string file specification, which can include wildcard
characters, for one or more files to be copied. destination Required. Character string destination where the file or files from source
are to be copied. Wildcard characters are not allowed. overwrite Optional. Boolean value that indicates if existing files are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite. Remarks Wildcard characters can only be used in the last path component of the source argument. For example, you can use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocumentsletters*.doc", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder" But you cannot use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocuments*R1???97.xls", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder" If source contains wildcard characters or destination ends with a path separator (), it is assumed that destination is an existing folder in which
to copy matching files. Otherwise, destination is assumed to be the name of
a file to create. In either case, three things can happen when an individual
file is copied.
a.. If destination does not exist, source gets copied. This is the usual case. b.. If destination is an existing file, an error occurs if overwrite is false. Otherwise, an attempt is made to copy source over the existing file.
c.. If destination is a directory, an error occurs. An error also occurs if a source using wildcard characters doesn't match any
files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message news:%
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en connaissant l'extension d'un fichier et/ou le début d'un fichier. L'équivalent de copy c:documents*.doc c:test. ou copy c:documentsLettre????.* c:test sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1,
false).
merci
merci, je vais essayer tout de suite.
"Jacques Barathon [MS]" <jbaratho@online.microsoft.com> a écrit dans le
message de news:efE2JPiyEHA.2568@TK2MSFTNGP10.phx.gbl...
CopyFile, extrait du Platform SDK:
***
Copies one or more files from one location to another.
object.CopyFile ( source, destination[, overwrite] )
Arguments
object
Required. The object is always the name of a FileSystemObject.
source
Required. Character string file specification, which can include
wildcard
characters, for one or more files to be copied.
destination
Required. Character string destination where the file or files from
source
are to be copied. Wildcard characters are not allowed.
overwrite
Optional. Boolean value that indicates if existing files are to be
overwritten. If true, files are overwritten; if false, they are not. The
default is true. Note that CopyFile will fail if destination has the
read-only attribute set, regardless of the value of overwrite.
Remarks
Wildcard characters can only be used in the last path component of the
source argument. For example, you can use:
[JScript]
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile ("c:\mydocuments\letters\*.doc", "c:\tempfolder\")
[VBScript]
FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder"
But you cannot use:
[JScript]
fso = new ActiveXObject("Scripting.FileSystemObject");
fso.CopyFile ("c:\mydocuments\*\R1???97.xls", "c:\tempfolder")
[VBScript]
FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder"
If source contains wildcard characters or destination ends with a path
separator (), it is assumed that destination is an existing folder in
which
to copy matching files. Otherwise, destination is assumed to be the name
of
a file to create. In either case, three things can happen when an
individual
file is copied.
a.. If destination does not exist, source gets copied. This is the usual
case.
b.. If destination is an existing file, an error occurs if overwrite is
false. Otherwise, an attempt is made to copy source over the existing
file.
c.. If destination is a directory, an error occurs.
An error also occurs if a source using wildcard characters doesn't match
any
files. The CopyFile method stops on the first error it encounters. No
attempt is made to roll back or undo any changes made before an error
occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message
news:%238boiZOyEHA.1524@TK2MSFTNGP09.phx.gbl...
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en
connaissant l'extension d'un fichier et/ou le début d'un fichier.
L'équivalent de copy c:documents*.doc c:test.
ou copy c:documentsLettre????.* c:test
sans passer par les commandes du type WshShell.Run("cmd copy *.doc ",
1,
"Jacques Barathon [MS]" a écrit dans le message de news:
CopyFile, extrait du Platform SDK:
*** Copies one or more files from one location to another. object.CopyFile ( source, destination[, overwrite] ) Arguments object Required. The object is always the name of a FileSystemObject. source Required. Character string file specification, which can include wildcard
characters, for one or more files to be copied. destination Required. Character string destination where the file or files from source
are to be copied. Wildcard characters are not allowed. overwrite Optional. Boolean value that indicates if existing files are to be overwritten. If true, files are overwritten; if false, they are not. The default is true. Note that CopyFile will fail if destination has the read-only attribute set, regardless of the value of overwrite. Remarks Wildcard characters can only be used in the last path component of the source argument. For example, you can use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocumentsletters*.doc", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocumentsletters*.doc", "c:tempfolder" But you cannot use:
[JScript] fso = new ActiveXObject("Scripting.FileSystemObject"); fso.CopyFile ("c:mydocuments*R1???97.xls", "c:tempfolder") [VBScript] FileSystemObject.CopyFile "c:mydocuments*R1???97.xls", "c:tempfolder" If source contains wildcard characters or destination ends with a path separator (), it is assumed that destination is an existing folder in which
to copy matching files. Otherwise, destination is assumed to be the name of
a file to create. In either case, three things can happen when an individual
file is copied.
a.. If destination does not exist, source gets copied. This is the usual case. b.. If destination is an existing file, an error occurs if overwrite is false. Otherwise, an attempt is made to copy source over the existing file.
c.. If destination is a directory, an error occurs. An error also occurs if a source using wildcard characters doesn't match any
files. The CopyFile method stops on the first error it encounters. No attempt is made to roll back or undo any changes made before an error occurs.
***
Jacques
"---DGI 972---" <wanagdermigny@*wanadoo.fr> wrote in message news:%
Bonjour,
Je voudrais savoir comment faire pour copier des fichiers en VBScript en connaissant l'extension d'un fichier et/ou le début d'un fichier. L'équivalent de copy c:documents*.doc c:test. ou copy c:documentsLettre????.* c:test sans passer par les commandes du type WshShell.Run("cmd copy *.doc ", 1,