replace
Replace existing files in a directory. If used with the /a option, this command adds new files to a directory instead of replacing existing files.
Syntax
Parameters
]
]
Remarks
As this command adds or replaces files, the file names appear on the screen. After this command is done, a summary line is displayed in one of the following formats:
If you’re using floppy disks and you need to switch disks while running this command, you can specify the /w command-line option so that this command waits for you to switch the disks.
You can’t use this command to update hidden files or system files.
The following table shows each exit code and a brief description of its meaning:
Exit code | Description |
---|---|
0 | This command successfully replaced or added the files. |
1 | This command encountered an incorrect version of MS-DOS. |
2 | This command couldn’t find the source files. |
3 | This command couldn’t find the source or destination path. |
5 | The user doesn’t have access to the files that you want to replace. |
8 | There is insufficient system memory to carry out the command. |
11 | The user used the wrong syntax on the command line. |
You can use the ERRORLEVEL parameter on the if command line in a batch program to process exit codes that are returned by this command.
Replace in Files
Replace in Files allows you to search the code of a specified set of files for a string or expression, and change some or all of the matches found. The matches found and actions taken are listed in the Find Results window selected in Result options.
The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, for example to General or Visual C++ settings, choose Tools > Import and Export Settings, and then choose Reset all settings.
You can use any of the following methods to display Replace in Files in the Find and Replace window.
To display Replace in Files
On the Edit menu, expand Find and Replace.
Choose Replace in Files.
If the Find and Replace window is already open, on the toolbar, choose Replace in Files.
Find what
To search for a new text string or expression, specify it in the box. To search for any of the 20 strings that you searched for most recently, open the drop-down list and choose the string. Choose the adjacent Expression Builder button if you want to use one or more regular expressions in your search string. For more information, see Use regular expressions in Visual Studio.
The Expression Builder button will only be enabled if you have selected Use Regular Expressions under Find options.
Replace With
To replace instances of the string in the Find what box with another string, enter the replacement string in the Replace With box. To delete instances of the string in the Find what box, leave this field blank. Open the list to display the 20 strings for which you searched most recently. Choose the adjacent Expression Builder button if you want to use one or more regular expressions in your replacement string. For more information, see Use regular expressions in Visual Studio.
Look in
The option chosen from the Look in drop-down list determines whether Replace in Files searches only in currently active files or searches all files stored within certain folders. Select a search scope from the list, type a folder path, or click the Browse (. ) button to display the Choose Search Folders dialog box and choose a set of folders to search. You can also type a path directly into the Look in box.
If the Look in option selected causes you to search a file that you have checked out from source code control, only the version of that file which has been downloaded to your local machine is searched.
Find options
You can expand or collapse the Find options section. The following options can be selected or cleared:
Match case
When selected, the Find Results windows will only display instances of the Find what string that are matched both by content and by case. For example, a search for «MyObject» with Match case selected will return «MyObject» but not «myobject» or «MYOBJECT.»
Match whole word
When selected, the Find Results windows will only display instances of the Find what string that are matched in complete words. For example, a search for «MyObject» will return «MyObject» but not «CMyObject» or «MyObjectC.»
Use Regular Expressions
When this check box is selected, you can use special notations to define patterns of text in the Find what or Replace with text boxes. For a list of these notations, see Use regular expressions in Visual Studio.
Look at these file types
This list indicates the types of files to search through in the Look in directories. If this field is left blank, all of the files in the Look in directories will be searched. Select any item in the list to enter a preconfigured search string that will find files of those particular types.
Result options
You can expand or collapse the Result options section. The following options can be selected or cleared:
Find Results 1 window
When selected, the results of the current search will replace the content of the Find Results 1 window. This window opens automatically to display your search results. To open this window manually, select Other Windows from the View menu and choose Find Results 1.
Find Results 2 window
When selected, the results of the current search will replace the content of the Find Results 2 window. This window opens automatically to display your search results. To open this window manually, select Other Windows from the View menu and choose Find Results 2.
Display file names only
When this check box is selected, the Find Results windows list the full names and paths for all files that contain the search string. However, the results don’t include the line of code where the string appears. This check box is available for Find in Files only.
Keep modified files open after Replace All
When selected, leaves open all files in which replacements have been made, so you can undo or save the changes. Memory constraints might limit the number of files that can remain open after a replace operation.
You can use Undo only on files that remain open for editing. If this option is not selected, files that were not already open for editing will remain closed, and no Undo option will be available in those files.
replace replace
Замена существующих файлов в каталоге. Replace existing files in a directory. При использовании с параметром /a эта команда добавляет новые файлы в каталог вместо того, чтобы заменять существующие файлы. If used with the /a option, this command adds new files to a directory instead of replacing existing files.
Синтаксис Syntax
Параметры Parameters
Параметр Parameter | Описание Description |
---|---|
[ :][ |
]
]
Комментарии Remarks
Так как эта команда добавляет или заменяет файлы, имена файлов отображаются на экране. As this command adds or replaces files, the file names appear on the screen. По завершении этой команды отображается строка сводки в одном из следующих форматов: After this command is done, a summary line is displayed in one of the following formats:
Если вы используете гибкие диски и вам необходимо переключить диски при выполнении этой команды, можно указать параметр командной строки /w , чтобы эта команда ожидает переключения дисков. If you’re using floppy disks and you need to switch disks while running this command, you can specify the /w command-line option so that this command waits for you to switch the disks.
Эту команду нельзя использовать для обновления скрытых файлов или системных файлов. You can’t use this command to update hidden files or system files.
В следующей таблице показан каждый код выхода и краткое описание его значения. The following table shows each exit code and a brief description of its meaning:
Код выхода Exit code | Описание Description |
---|---|
0 0 | Эта команда успешно заменила или добавила файлы. This command successfully replaced or added the files. |
1 1 | Эта команда обнаружила неправильную версию MS-DOS. This command encountered an incorrect version of MS-DOS. |
2 2 | Этой команде не удалось найти исходные файлы. This command couldn’t find the source files. |
3 3 | Этой команде не удалось найти исходный или конечный путь. This command couldn’t find the source or destination path. |
5 5 | У пользователя нет доступа к файлам, которые требуется заменить. The user doesn’t have access to the files that you want to replace. |
8 8 | Недостаточно системной памяти для выполнения команды. There is insufficient system memory to carry out the command. |
11 11 | Пользователь использовал неправильный синтаксис в командной строке. The user used the wrong syntax on the command line. |
Можно использовать параметр ERRORLEVEL в командной строке If в пакетной программе для обработки кодов завершения, возвращаемых этой командой. You can use the ERRORLEVEL parameter on the if command line in a batch program to process exit codes that are returned by this command.