07-23-2023, 12:21 AM
I want to create a batch file, `batch.bat`, that accepts 2 mandatory arguments:
- `%1` represents a path relative to the current directory.
- `%2` represents a filaname.
Assume the current directory is `father\me\`.
User can use this batch as follows:
- `batch child/grandchild log`
- `batch ../brother log`
The job description of `batch.bat` is as follows.
1. Moves to `%1` directory,
2. Iterates all `*.tex` file in the `%1` directory.
3. Save the result in the directory before moving.
The following is the incomplete code:
rem batch.bat takes 2 arguments.
cd %1
dir /b *.tex > <original directory>\%2.txt
How to return to the original directory after invoking change directory in DOS batch?
- `%1` represents a path relative to the current directory.
- `%2` represents a filaname.
Assume the current directory is `father\me\`.
User can use this batch as follows:
- `batch child/grandchild log`
- `batch ../brother log`
The job description of `batch.bat` is as follows.
1. Moves to `%1` directory,
2. Iterates all `*.tex` file in the `%1` directory.
3. Save the result in the directory before moving.
The following is the incomplete code:
rem batch.bat takes 2 arguments.
cd %1
dir /b *.tex > <original directory>\%2.txt
How to return to the original directory after invoking change directory in DOS batch?