Outils pour utilisateurs

Outils du site


info:copy

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

info:copy [2022/10/13 12:57] – créée froginfo:copy [2022/10/13 12:59] (Version actuelle) frog
Ligne 3: Ligne 3:
  
  
-Copy Command+==== Copy Command ==== 
 On Windows, we can use the copy command to copy one or more files from one location to another: On Windows, we can use the copy command to copy one or more files from one location to another:
  
Ligne 11: Ligne 12:
 Use the /y switch to overwrite duplicate files without confirmation: Use the /y switch to overwrite duplicate files without confirmation:
  
-copy /y C:\data\sales.doc C:\backup+<code>copy /y C:\data\sales.doc C:\backup</code>
 We can also save a file to a different name. For example, the following command saves file1.txt as file2.txt in the same directory: We can also save a file to a different name. For example, the following command saves file1.txt as file2.txt in the same directory:
  
-copy file1.txt file2.txt+<code>copy file1.txt file2.txt</code>
 You can also use wildcards to copy multiple files: You can also use wildcards to copy multiple files:
  
-copy /y C:\data\* C:\backup +<code>copy /y C:\data\* C:\backup 
-copy /y C:\data\*.doc C:\backup+copy /y C:\data\*.doc C:\backup</code>
 The first command copies all files in the C:\data\ directory to C:\backup. The second command copies all files with a .doc extension to the C:\backup. The first command copies all files in the C:\data\ directory to C:\backup. The second command copies all files with a .doc extension to the C:\backup.
  
Ligne 24: Ligne 25:
 We can also combine several files into one: We can also combine several files into one:
  
-copy file1+file2 file3 +<code>copy file1+file2 file3 
-copy error* C:\backup\report.txt+copy error* C:\backup\report.txt</code>
 In the first line, file1 and file2 are combined to make one file named file3. In the second line, all files whose names start with "error" are copied to the C:\backup, as a single file called report.txt. In the first line, file1 and file2 are combined to make one file named file3. In the second line, all files whose names start with "error" are copied to the C:\backup, as a single file called report.txt.
  
 You can get a list of all available options with the copy /? command. You can get a list of all available options with the copy /? command.
  
-Xcopy Command+==== Xcopy Command ==== 
 The xcopy command offers more features. For example, with xcopy, we can copy directories and subdirectories, as well as hidden files. The xcopy command offers more features. For example, with xcopy, we can copy directories and subdirectories, as well as hidden files.
  
Ligne 48: Ligne 50:
 Copy sales.doc from the current directory to C:\backup: Copy sales.doc from the current directory to C:\backup:
  
-xcopy sales.doc C:\backup+<code>xcopy sales.doc C:\backup</code>
 Copy C:\data\accounts (all files including subdirectories) to C:\backup: Copy C:\data\accounts (all files including subdirectories) to C:\backup:
  
-xcopy /s /e /h /i /y C:\data\accounts C:\backup\accounts +<code>xcopy /s /e /h /i /y C:\data\accounts C:\backup\accounts 
-xcopy command+xcopy command</code>
 In the following example (without /I switch), the contents of the folder are copied but not the folder itself: In the following example (without /I switch), the contents of the folder are copied but not the folder itself:
  
-xcopy /s /e /h /y C:\data\accounts C:\backup\+<code>xcopy /s /e /h /y C:\data\accounts C:\backup\</code>
 Copy the directory structure of C:\OneDrive to the backup directory: Copy the directory structure of C:\OneDrive to the backup directory:
  
-xcopy /s /e /t /y C:\OneDrive C:\backup\+<code>xcopy /s /e /t /y C:\OneDrive C:\backup\</code>
 You can use wildcard characters to match patterns. The following command copies all files with a .jpg extension: You can use wildcard characters to match patterns. The following command copies all files with a .jpg extension:
  
-xcopy /s /h /y C:\data\*.jpg C:\backup+<code>xcopy /s /h /y C:\data\*.jpg C:\backup</code>
 Using for loop to copy multiple files: Using for loop to copy multiple files:
  
-for %i in (sales.doc, products.doc) do xcopy /y %i C:\backup+<code>for %i in (sales.doc, products.doc) do xcopy /y %i C:\backup</code>
 Excluding files with xcopy Excluding files with xcopy
 With the /exclude, we can provide a text file that contains items we want to exclude. With the /exclude, we can provide a text file that contains items we want to exclude.
  
-xcopy /s /e /h /y /exclude:C:\Users\user1\files-to-exclude.txt C:\data\ C:\backup\+<code>xcopy /s /e /h /y /exclude:C:\Users\user1\files-to-exclude.txt C:\data\ C:\backup\</code>
 The files-to-exclude.txt may look like the following: The files-to-exclude.txt may look like the following:
  
info/copy.1665658645.txt.gz · Dernière modification : de frog