BAT read file and write file

@echo off
setlocal enableextensions
setlocal enabledelayedexpansion
for /f "tokens=1 delims= " %%m in (sys.out) do (
set num=%%m
if /i !num! equ 5 (
echo 1 >nsys.out
del sys.out && move nsys.out sys.out
) else (
set old=%%m
set /a newN=!old!+1
echo !newN! >nsys.out
del sys.out && move nsys.out sys.out
)
)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WELCOME TO TURBO C 2.0 ---------------------- This README file contains important, last minute information about Turbo C 2.0. The HELPME!.DOC file on the COMMAND LINE/UTILITIES disk also answers many common Technical Support questions. TABLE OF CONTENTS ----------------- 1. How to Get Help 2. Installation 3. Important Notes 4. Corrections to the Manuals 5. Additional Notes 6. Notes for Turbo Prolog Users 7. Files on the Disks 1. HOW TO GET HELP ------------------- If you have any problems, please read this file, the HELPME!.DOC file, and the Turbo C manuals first. If you still have a question and need assistance, help is available from the following sources: 1. Type GO BOR on the CompuServe bulletin board system for instant access to the Borland forums with their libraries of technical information and answers to common questions. If you are not a member of CompuServe, see the enclosed special offer, and write for full details on how to receive a free IntroPak containing a $15 credit toward your first month's on- line charges. 2. Check with your local software dealer or users' group. 3. Write to us at the following address: Borland International Turbo C Technical Support 1800 Green Hills Road P.O. Box 660001 Scotts Valley, CA 95066-0001 Please remember to include your serial number or we will be unable to process your letter. 4. If you have an urgent problem that cannot wait and you have sent in the license agreement from the front of your manual, you may call the Borland Technical Support Department at (408) 438-5300. Please have the following information ready before calling: a. Product name and serial number on your original distribution disk. Please have your serial number ready or we will be unable to process your call. b. Product version number. The version number for Turbo C is displayed when you first load the program and before you press any keys. c. Computer brand, model, and the brands and model numbers of any additional hardware. d. Operating system and version number. (The version number can be determined by typing VER at the MSDOS prompt.) e. Contents of your AUTOEXEC.BAT file. f. Contents of your CONFIG.SYS file. 2. INSTALLATION ---------------- The INSTALL/HELP disk contains a program called INSTALL.EXE that will assist you with the installation of Turbo C 2.0. There are three options for installation: 1. Hard Disk - This option allows you to pick the subdirectories where the files will be loaded. It will create a TURBOC.CFG file based on those directories. 2. Update from TC 1.5 - This allows for an easy update from version 1.5. After the files are copied, all the installed options from your current TC.EXE will be transferred to the new one. This is especially useful if you have modified the colors or editor keys. 3. Floppy Disk - This option will build either a command line or Integrated Development Environment version for a two drive system. Be sure to have three formatted disks ready before you start. To start the installation, change your current drive to the one that has the install program on it and type INSTALL. You will be given instructions in a box at the bottom of the screen for each prompt. For example, if you will be installing from drive A:, type: A: INSTALL You should read the rest of this README file to get further information about this release before you do the installation. 3. IMPORTANT NOTES ------------------- o The file HELPME!.DOC contains discussions of common questions and answers concerning Turbo C 2.0. You should consult it for answers to problems that aren't covered in this file or in the manuals. o If you are running INSTALL or TCINST on a laptop or any other system that uses an LCD or composite display, you should set your system to black and white mode before running INSTALL or TCINST. You can do this from DOS with the following command line: mode bw80 or, you can force INSTALL or TCINST to come up in black and white mode by using the /b switch: tcinst /b o /P PARAMETER FOR TC.EXE. A new command-line switch controls palette swapping on EGA video adapters. Using this switch tc /p hello is recommended only when the user program modifies the EGA palette registers. When /P is specified, the EGA palette will be restored each time the screen is swapped. In general, you don't need to use this switch unless your program modifies the EGA palette registers, or unless your program uses BGI to change the palette. o A program that takes over interrupt 9 cannot be debugged with the integrated debugger. Use the standalone Turbo Debugger instead. o exec() WITH NOVELL NETWORK. Versions of the Novell network system software earlier than 2.01-2 do not support a DOS call used by exec(), spawn(), and system(). If you are using the Integrated Development Environment to run a program that uses any of these functions and you have early Novell system software, run the program from DOS. To do this from the Integrated Development Environment you can use Alt-F/O. o If you used the INSTALL program to upgrade from version 1.5, or if you used CINSTXFR to transfer options from an installation of version 1.5, check the setting of the standard stack frame option in the Integrated Development Environment (Alt-O/C/C/S). If you are going to use the integrated debugger this option should be turned ON. o If you are having problems with the call stack or qualified names, make sure you have compiled with the standard stack frame option turned on. o The ANSI draft has changed the syntax of labels. A label now must always be followed by a statement. This means that code like this is no longer accepted: { . . . jump_label: } If you have code like this, change it to look like this: { . . . jump_label: ; /* need a statement here! */ } o TCC has a switch to specify which assembler to look for. By default, it will look for TASM.EXE. If you want to use a different assembler, use -E<filename>, as described in the Reference Guide. o When using THELP on an AT&T 6300, be sure to use the /L25 command-line option, as described in the file THELP.DOC. o When you use qualified variable names as described on page 57 of the User's Guide you don't need to use the module name to access a variable that is local to a global function. The module name is only needed when you access a static variable or a variable that is local to a static function. o Because of the limited memory available in the Tiny model, it no longer supports graphics functions. o The Version 1.5 graphics drivers (*.BGI) are not compatible with the Version 2.0 graphics library. Use the graphics drivers distributed with Version 2.0. o When used with a Zenith Z-449 card, the BGI autodetection code will always select the 640X480 enhanced EGA mode. If you are using the Z-449 with a monitor that is not compatible with this mode, it will be necessary to override the GraphDriver and GraphMode parameters used in the BGI initgraph() call. 4. CORRECTIONS TO THE MANUALS ------------------------------ REFERENCE GUIDE: Page 159 The prototype for the function getdefaultpallette() is incorrect. It should be struct palettetype * far _Cdecl getdefaultpalette( void ); USER'S GUIDE: Page 57 In the section entitled "Qualifying Variable Names," the last sentence should read "...need to type only myfunc.myvar." 66 The directions for compiling the WORDCNT program are incorrect. There is no WORDCNT.PRJ file; all you need to do is load the file WORDCNT.C into the editor. Once you have done that, the rest of the instructions are correct. 5. ADDITIONAL NOTES -------------------- 5.1 NOTES FOR VERSION 1.0 & 1.5 USERS ------------------------------------- o You must use the Version 2.0 libraries with the 2.0 compilers. o The Integrated Development Environment no longer displays the message "Press any key to return to Turbo C..." when your program terminates. Instead, at the end of your program the User screen is replaced by the Integrated Development Environment. To view the User screen, press Alt-F5 or select Alt-R/S. When you are viewing the User screen, pressing any key will return you to the Integrated Development Environment. o A new pseudo-variable has been added. _FLAGS now contains the value of the flags register so you can test the flags at any point in your program. o The ssignal() and gsignal() functions are no longer supported. See the section in this README on how to convert programs that use them. o The cprintf() function now works as documented. It does not translate line-feeds into CR/LF combinations. o Some compatibles had a problem under Version 1.5 because it used interrupt 18H. Version 2.0 does not use this interrupt, so you shouldn't encounter this problem anymore. o The program TCINST.COM in Version 1.0 has been changed to an .EXE file. You should delete the TCINST.COM program before trying to run the new TCINST.EXE. Otherwise, MS-DOS will actually run the old one. o The FILE structure for streams in Version 1.0 (but not 1.5) has been changed, so that the function tmpfile() could be implemented. You should recompile any modules that use stream I/O. 5.2 THELP ---------- THELP is a memory-resident utility program that gives you access to the Turbo C context-sensitive help system from any program. You don't need to use THELP if you're in the Integrated Development Environment, but it is especially useful if you use the command line compiler and your own text editor, or if you are debugging with the standalone Turbo Debugger. To use THELP, load THELP.COM into memory by typing at the DOS command line: thelp You activate ("pop-up") THELP by typing its hot key -- by default numeric keypad <5>. All Turbo C help commands apply (F1, Ctrl-F1, Alt-F1). For a complete description of THELP, refer to THELP.DOC in the Documentation Subdirectory. 5.3 USING CINSTXFR.EXE ---------------------- Your Turbo C 2.0 package contains a program named CINSTXFR.EXE, which can be used to transfer the configuration of the Integrated Development Environment from your copy of Turbo C 1.5 (not for 1.0) to your new installation of Turbo C 2.0. This program is run automatically by INSTALL.EXE if you select the option to "Update Hard Drive Copy of Turbo C 1.5 to Turbo C 2.0." If you prefer to do this yourself, you can run CINSTXFR.EXE from the DOS command line. CINSTXFR.EXE takes two arguments: the first is the name of your Turbo C 1.5 Integrated Development Environment file (usually TC.EXE), and the second is the name of your Turbo C 2.0 Integrated Development Environment file (also usually TC.EXE). Either one of these names can also include a path name. For example, if your copy of the Turbo C 1.5 Integrated Development Environment file is named TC.EXE and is in a directory named \TURBOC and your copy of the Turbo C 2.0 Integrated Development Environment file is also named TC.EXE but is located in a directory named \TC2, the command line to copy the configuration from 1.5 to 2.0 would look like this: CINSTXFR \TURBOC\TC.EXE \TC2\TC.EXE This will transfer all the options that you installed in your copy of Turbo C 1.5 to your copy of Turbo C 2.0. CINSTXFR.EXE does not work with Turbo C 1.0. If you are upgrading from Turbo C 1.0, you will have to install the options yourself. 5.4 CHANGED SWITCHES FOR OBJXREF -------------------------------- OBJXREF is an object module cross reference utility and is described on page 528 of the Turbo C Reference Guide. The /O option (object files directory) has been changed to the /D (directories) option. The switch now allows for multiple search directories to be specified. The new syntax is: OBJXREF /Ddir1[;dir2[;dir3]] or OBJXREF /Ddir1 [/Ddir2] [/Ddir3] OBJXREF will search each of the directories in the specified order for all object and library files. If no /D option is used, only the current directory will be searched. However, if a /D option is used, the current directory will NOT be searched unless it is included in the directory list. For example, to first search the BORLAND directory for files and then search the current directory, you would type OBJXREF /Dborland;. If multiple search directories are specified and a file matching the file specification is found, OBJXREF will include the file as part of the cross-reference. OBJXREF will only continue to search the other directories for the same file specification if the file specification contains wildcards. A new option has been added to allow you to specify an output file where OBJXREF will send any reports generated. The new option is the /O option, and has the following syntax: OBJXREF myfile.obj /RU /Ofilename.ext By default, all output is sent to the console. 5.5 CONVERSION INFORMATION FOR ssignal() AND gsignal() ------------------------------------------------------ Note: The C library and SIGNAL.H no longer support the ssignal() and gsignal() functions. ssignal() and gsignal() were from the old UNIX System III days. The ANSI standard no longer supports them nor does the current UNIX System V Interface Definition specification. To ease portation problems for people moving older code to Turbo C, we supply the source for the functions that came with TC 1.0 and TC 1.5. Also, the following discussion describes how code can be converted to do the same sort of things that ssignal() and gsignal() do without actually using them. NOTE: The constants defined in SIGNAL.H for SIG_IGN and SIG_DFL are different from the constants that were in TC 1.0 and TC 1.5. By using a globally declared array of function pointers, you can simulate the actions of ssignal() and gsignal() by using the following macros. Notice how the global table entry [0] is used as a temporary variable in the ssignal macro allowing the macro to swap the values and still return the original one. int (*_sigTable[16]) = { SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, SIG_IGN, }; #define ssignal(num, action) \ ( \ (((num) < 1) || ((num) > 15)) ? SIG_DFL : \ ( \ (_sigTable[0] = _sigTable[(num)]), /* List of actions */ \ _sigTable[(num)] = (action), /* The last expression */ \ _sigTable[0] /* is the return value */ \ ) \ ) \ #define gsignal(num) \ ( \ (((num) < 1) || ((num) > 15)) ? 0 : \ ( \ (_sigTable[(num)] == SIG_IGN) ? 1 : \ ( \ (_sigTable[(num)] == SIG_DFL) ? 0 : (*_sigTable[(num)])() \ ) \ ) \ ) \ 6. NOTES FOR TURBO PROLOG USERS -------------------------------- o If you are linking C code with programs generated by Turbo Prolog 2.0, use the file INIT.OBJ provided on the EXAMPLES/BGI/MISC disk of the Turbo C 2.0 package instead of the file provided with Turbo Prolog 2.0. There have been some changes made in Turbo C 2.0 that require the use of this new file. o If your C code uses floating point math and you link with the emulator library, Prolog will not automatically detect a math coprocessor chip. If you want to force the program to use the coprocessor, link it with FP87.LIB instead of EMU.LIB. 7. FILES ON THE DISKS ---------------------- INSTALL/HELP ------------ INSTALL EXE - Installation program README COM - Reads this README TCHELP TCH - Help file for Turbo C THELP COM - Pop-up utility to access TCHELP.TCH THELP DOC - Documentation for THELP.COM README - This file INTEGRATED DEVELOPMENT ENVIRONMENT ---------------------------------- TC EXE - Turbo C Compiler TCCONFIG EXE - Program to convert configuration files MAKE EXE - Program for managing projects GREP COM - Turbo GREP program TOUCH COM - Program that updates a file's date and time COMMAND LINE/UTILITIES ---------------------- TCC EXE - Command-line version of Turbo C Compiler CPP EXE - Turbo C preprocessor TCINST EXE - Installation program for TC.EXE TLINK EXE - Borland Turbo Linker HELPME! DOC - Common questions and answers LIBRARIES --------- C0S OBJ - Small model startup code C0T OBJ - Tiny model startup code C0L OBJ - Large model startup code MATHS LIB - Small model math library MATHL LIB - Large model math library CS LIB - Small model run-time library CL LIB - Large model run-time library EMU LIB - 8087 emulator library GRAPHICS LIB - Graphics library FP87 LIB - 8087 library TLIB EXE - Borland Turbo Librarian HEADER FILES/LIBRARIES ---------------------- ???????? H - Turbo C header files <SYS> - Subdirectory with SYS\*.H header files C0C OBJ - Compact model startup code C0M OBJ - Medium model startup code MATHC LIB - Compact model math library MATHM LIB - Medium model math library CC LIB - Compact model run-time library CM LIB - Medium model run-time library EXAMPLES/BGI/MISC ----------------- UNPACK COM - Program to unpack the .ARC files OBJXREF COM - Object file cross-reference utility C0H OBJ - Huge model startup code MATHH LIB - Huge model math library CH LIB - Huge model run-time library GETOPT C - Parses options in command line HELLO C - Example Turbo C program MATHERR C - Source code for handling math library exceptions SSIGNAL C - Source code for ssignal and gsignal functions CINSTXFR EXE - Program to copy TC 1.5 installation to TC 2.0 INIT OBJ - Initialization code for use when linking with Prolog BGI ARC - BGI drivers and fonts BGIOBJ EXE - Conversion program for fonts and drivers ATT BGI - Graphics driver for ATT400 graphics card CGA BGI - Graphics driver for CGA EGAVGA BGI - Graphics driver for EGA and VGA HERC BGI - Graphics driver for Hercules IBM8514 BGI - Graphics driver for IBM 8514 graphics card PC3270 BGI - Graphics driver for PC3270 GOTH CHR - Font for gothic character set LITT CHR - Font for small character set SANS CHR - Font for sans serif character set TRIP CHR - Font for triplex character set BGIDEMO C - Graphics demonstration program STARTUP ARC - ARC file with startup source code and related files RULES ASI - Assembler include file for interfacing with Turbo C C0 ASM - Assembler source for startup code SETARGV ASM - Assembler source code for parsing the command line SETENVP ASM - Assembler source code for preparing the environment BUILD-C0 BAT - Batch file for building the startup code modules MAIN C - Alternative, stripped-down C main file EMUVARS ASI - Assembler variable declarations for emulator WILDARGS OBJ - Object code for module to expand wildcard arguments EXAMPLES ARC - Various C examples code CPASDEMO PAS - Pascal program that demonstrates Turbo Pascal 4.0 - Turbo C interface CPASDEMO C - C example module for the Turbo Pascal 4.0 - Turbo C interface demonstration CTOPAS TC - Configuration file for use with TC.EXE that creates Turbo C modules in the correct format for linking with Turbo Pascal 4.0 programs CBAR C - Example function to be used with PBAR.PRO PBAR PRO - Example Turbo Prolog program demonstrating interface with Turbo C WORDCNT C - Example program demonstrating source level debugging. NOTE: DO NOT RUN THIS PROGRAM WITHOUT READING THE DISCUSSION IN THE MANUAL. IT CONTAINS DELIBERATE ERRORS. WORDCNT DAT - Data file for use by WORDCNT.C MCALC ARC - Mcalc sources and doc MCALC DOC - MicroCalc documentation MCALC C - MicroCalc main program source code MCINPUT C - MicroCalc input routines source code MCOMMAND C - MicroCalc commands source code MCPARSER C - MicroCalc input parser source code MCUTIL C - MicroCalc utilities source code MCDISPLY C - MicroCalc screen display source code MCALC H - The header file for MicroCalc MCALC PRJ - The MicroCalc project file
vbs 批量修改文件,bat 批处理文件调用执行vbs,并在cmd窗口打印返回值(vbs运行结果) 使用vbs 脚本对工作目录下的字符串进行替换并统计被修改的文件数主调的批处理方法将捕捉该vbs脚本运行后的结果并打印在cmd窗口。 示例代码(t.vbs)如下: Set fso=Wscript.CreateObject("Scripting.FileSystemObject") flrName="D:\Workspace\src\" 'dir that you need deal with count=0 'get the count of modified files function Traversal(dir) set flr=fso.getfolder(dir) set fs=flr.files findstr1="[assembly: SecurityTransparent]" 'find string that need to be replaced findstr2=replace(findstr1," ","") 'becasuse there isspace char in findstr,so add this findstr2 replaceStr="[assembly: AllowPartiallyTrustedCallers()]" 'destination stringin replace for each f in fs if lcase(f.name)="assemblyinfo.cs" then set findf=fso.opentextfile(f) do while findf.atendofstream=false d=f.datelastmodified 'get modified datetime of current file alltext=findf.readall if(InStr(alltext,findstr1)> 0 ) then s=replace(alltext,findstr1, replaceStr) count=count+1 findf.close() 'If no findstr2, delete the following elseif block elseif(InStr(alltext,findstr2) > 0) then s=replace(alltext,findstr2, replaceStr) count=count+1 findf.close() else findf.close() exit do end if set r=fso.opentextfile(f, 2, true) r.write s d2=f.datelastmodified if d2>=d then exit do loop end if next set fs=flr.subfolders for each f in fs Traversal(f.path) next end function Traversal(flrName) 'msgbox ("Done! "& count &" files were modified successfully.") wscript.echo "Done! "& count & " files were modified successfully." 'value popup by"wscript.echo" can be received by .bat easily Wscript.quit count 'this variable "count" in order to get a return value by%ErrorLevel% 上面的操作只执行了处理文件的步骤 如果不需要提取运行结果,在 批处理 或主调vbs脚本里直接 运行该vbs文件就行了。 如果在bat 里调用该vbs脚本,并希望打印出提示信息 可以用下面的两种方法来实现: 1,在bat中加入如下代码
1 , Manager.zipThis has assorted functions (file copy, time, settings, etc).2 , manc-html.zipAn example I did to retreive an Email Address or URL from an HTML file.3 , basFile.zipThis bas file is filled with assorted file related functions. If you work with file manipulation, then you should take a look at this.4 , dragdropfiles.zipThis example shows how you can support drag and drop functionality to your application in the form of images5 , assoc.zipThis example demonstrates how to edit the registry so your application is associated with a certain file extension.6 , watchdir.zipThis demonstrates how to watch a specific directory for any changes. An excellent idea for an Anti-Virus/Security program.7 , dellines.zip"Open the file and use Line Input to read lines. Write any that do not contain the target into a temporary file. Use Kill to remove the original file and then use Name to give the temporary file the old file name."8 , cpyfile.zipThis will copy a specified file to a directory. It also shows its progress through a Progress Bar.9 , cshort.zipThis demonstrates how to create a short-cut to a specific file. 10 , fsize.zipThis demonstrates how to retrieve the file size from a specified file.11 , cleardocs.zipThis will clear the documents on the Start Menu.12 , syscolor.zipThis is an example of how to retrieve the system colors and display them on your form.13 , findfiles.zipThis is an example of how to return all of the files on a users system. This can be easily edited to be close to the normal Windows' Find File or Folder Dialog.14 , Sorter13.zipAn updated version of The Sorter. Now you choose the file to save. Also, it can handle up to 1 MB now.15 , coolExplorer.zipA cool program that has the most basic functions of a windows explorer: Delete, Copy , Move... file viewing and
CFile //创建/打开文件 CFile file; file.Open(_T("test.txt"),CFile::modeCreate|CFile::modeNoTruncate|CFile::modeReadWrite); 文件打开模式可组合使用,用“|”隔开,常用的有以下几种: CFile::modeCreate:以新建方式打开,如果文件不存在,新建;如果文件已存在,把该文件长度置零,即清除文件原有内容。 CFile::modeNoTruncate:以追加方式打开,如果文件存在,打开并且不将文件长度置零,如果文件不存在,会抛出异常。一般与CFile::modeCreate一起使用,则文件不存在时,新建一个文件;存在就进行追加操作。 CFile::modeReadWrite:以读写方式打开文件。 CFile::modeRead:只读。 CFile::modeWrite:只写。 //写入数据 CString strValue = "Hello World!"; file.Write(strValue,strValue.GetLength()); //追加数据 file.SeekToEnd(); //将指针移至文件末尾进行追加 file.Write(strValue,strValue.GetLength()); //关闭文件 file.Close(); CStdioFile CStdioFile是CFile的派生类,对文件进行流式操作,对于文本文件的读写很有用处,可按行读取写入。 //写入数据 CString strValue = "Hello World!"; file.WriteString(strValue); //读取数据 CString strRead; file.ReadString(strRead); 当文件存在多行数据需要逐行读取时,可用函数BOOL CStdioFile::ReadString(CString& rString),当遇到"\n "时读取截断,如果文件未读完,返回true,否则返回false。 //逐行读取文件内容,存入strRead while(file.ReadString(strRead)) { ...; } 各种关于文件的操作在程序设计中是十分常见,如果能对其各种操作都了如指掌,就可以根据实际情况找到最佳的解决方案,从而在较短的时间内编写出高效的代码,因而熟练的掌握文件操作是十分重要的。本文将对Visual C++中有关文件操作进行全面的介绍,并对在文件操作中经常遇到的一些疑难问题进行详细的分析。   1.文件的查找   当对一个文件操作时,如果不知道该文件是否存在,就要首先进行查找。MFC中有一个专门用来进行文件查找的类CFileFind,使用它可以方便快捷地进行文件的查找。下面这段代码演示了这个类的最基本使用方法。   CString strFileTitle;   CFileFind finder;   BOOL bWorking = finder.FindFile("C:\\windows\\sysbkup\\*.cab");   while(bWorking)   {   bWorking=finder.FindNextFile();   strFileTitle=finder.GetFileTitle();   }   2.文件的打开/保存对话框   让用户选择文件进行打开和存储操作时,就要用到文件打开/保存对话框。MFC的类CFileDialog用于实现这种功能。使用CFileDialog声明一个对象时,第一个BOOL型参数用于指定文件的打开或保存,当为TRUE时将构造一个文件打开对话框,为FALSE时构造一个文件保存对话框。   在构造CFileDialog对象时,如果在参数中指定了OFN_ALLOWMULTISELECT风格,则在此对话框中可以进行多选操作。此时要重点注意为此CFileDialog对象的m_ofn.lpstrFile分配一块内存,用于存储多选操作所返回的所有文件路径名,如果不进行分配或分配的内存过小就会导致操作失败。下面这段程序演示了文件打开对话框的使用方法。   CFileDialog mFileDlg(TRUE,NULL,NULL,   OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT|OFN_ALLOWMULTISELECT,   "All Files (*.*)|*.*||",AfxGetMainWnd());   CString str(" ",10000);   mFileDlg.m_ofn.lpstrFile=str.GetBuffer(10000);   str
### 回答1: bat 文件是批处理文件,它是一种用于在 Windows 操作系统中执行命令的文本文件。在 bat 文件中,你可以写入多条命令,这些命令会依次执行。你可以通过双击 bat 文件来执行里面的命令,或者在命令提示符中输入文件名来执行。 相对文件路径是指相对于当前工作目录的文件路径。例如,假设当前工作目录是 C:\Work,并且在 C:\Work 目录中有一个名为 test.txt 的文件,那么 test.txt 的相对文件路径就是 "test.txt"。如果你在 bat 文件中使用了相对文件路径,那么它将会相对于当前工作目录进行解析。 举个例子,假设你在 C:\Work 目录中有一个 bat 文件,并且在 C:\Work 目录中有一个名为 test.txt 的文件,你可以在 bat 文件中写入命令来打开 test.txt 文件,例如: ``` notepad test.txt ``` 这条命令将会打开 C:\Work\test.txt 文件。 总之,bat 文件是一种在 Windows 中执行命令的文本文件,相对文件路径是指相对于当前工作目录的文件路径,可以在 bat 文件中使用相对文件路径来引用文件。希望这些信息能对你有所帮助。 ### 回答2: "bat relative file"指的是批处理文件中的相对路径。批处理文件是一种包含一系列命令的文本文件,用于自动化执行多个命令。在批处理文件中,文件的路径可以使用相对路径或绝对路径来指定。 相对路径是相对于当前工作目录的路径,而不是完整的文件路径。相对路径更容易在不同的环境中进行移植,因为它们不依赖于具体的文件系统结构。相对路径可以使用以下符号: 1. 单点(.):表示当前目录。例如,如果批处理文件位于D:\folder1\folder2\,使用相对路径.\file.txt将指向D:\folder1\folder2\file.txt。 2. 双点(..):表示上一级目录。例如,如果批处理文件位于D:\folder1\folder2\,使用相对路径..\file.txt将指向D:\folder1\file.txt。 3. 文件夹名称:可以直接使用文件夹的名称作为相对路径。例如,如果批处理文件位于D:\folder1\folder2\,使用相对路径folder3\file.txt将指向D:\folder1\folder2\folder3\file.txt。 使用相对路径的好处是,当批处理文件位于不同的文件夹中或被移动到其他位置时,路径仍然有效。相对路径也可以帮助简化批处理文件中的命令,因为不需要输入完整的文件路径。 但是,使用相对路径也可能会导致问题。如果批处理文件的当前目录不确定或改变,可能会导致相对路径无效。此外,如果文件路径很复杂,许多层嵌套文件夹,使用相对路径可能会变得更加困难。 总而言之,"bat relative file"表示批处理文件中使用的相对路径。相对路径可以简化批处理文件中的命令,并且更容易在不同的环境中移植。然而,在使用相对路径时需要注意目录结构和可能导致路径无效的情况。 ### 回答3: bat相对文件指的是在批处理文件中,通过相对路径来引用其他文件的方式。相对路径是基于当前批处理文件所在位置的路径。 在批处理文件中,可以使用相对路径引用其他文件,包括文本文件、可执行文件等。相对文件路径指定了文件相对于批处理文件所在位置的位置。 例如,如果我们有一个批处理文件(test.bat)位于D:\scripts\目录下,而我们想引用同一目录下的一个文本文件(data.txt),我们可以使用以下相对路径引用此文件:.\data.txt。其中,点号表示当前目录。 另外,如果我们希望引用上一级目录中的一个可执行文件(program.exe),我们可以使用以下相对路径:..\program.exe。其中,两个点号表示上一级目录。 使用相对文件路径的好处是,可以在批处理文件所在的文件夹位置灵活地引用其他文件,而无需指定完整的绝对路径。这使得批处理文件更加灵活和可移植,能够方便地在不同位置和计算机上使用。 总结而言,bat相对文件是指使用相对路径在批处理文件中引用其他文件的方式,能够提供灵活性和可移植性,使得批处理文件更加方便地在不同位置和计算机上使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值