替换一个文件中的内容BAT
@echo off
setlocal enabledelayedexpansion
set file=%1
set "file=%file:"=%"
for %%i in ("%file%") do set file=%%~fi
echo.
set replaced=%2
echo.
set all=%3
for /f "delims=" %%i in ('type "%file%"') do (
set str=%%i
set "str=!str:%replaced%=%all%!"
echo !str!>>"%file%"_tmp.txt
)
copy "%file%" "%file%"_bak.txt >nul 2>nul
move "%file%"_tmp.txt "%file%"
start "" "%file%"
替换一个文件中的内容BAT的更多相关文章
- java中的文件读取和文件写出:如何从一个文件中获取内容以及如何向一个文件中写入内容
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.Fi ...
- Java IO把一个文件中的内容以字符串的形式读出来
代码记录(备查): /** * 把一个文件中的内容以字符串的形式读出来 * * @author zhipengs * */ public class FileToString { public sta ...
- IO编程——复制一个文件中的内容到另一个文件
public class TestIO { public static void main(String[] args) { File inputFile = new File("a.txt ...
- FileWriter实现从一个文件中读取内容并写到另一个文件中
FileWriter和FileOutputStream都是向文件写内容,区别是前台一次写一个字符,后者一次写一个字节 package com.janson.day20180827; import ja ...
- linux shell 脚本获取和替换文件中特定内容
1.从一串字符串中获取特定的信息 要求1:获取本机IP:menu.lst为系统镜象的IP配置文件,需要从中获取到本机IP信息(从文件获取信息) timeout title live find --se ...
- Linux中一个文件10行内容,如何输出5-8内容到屏幕
题目是这样的,Linux中一个文件10行内容,如何输出5-8内容到屏幕首先我们模拟一下这样的环境: [root@localhost question]# pwd /root/question [roo ...
- 将一个文件中的内容,在另一个文件中生成. for line in f1, \n f2.write(line)
将一个文件中的内容,在另一个文件中生成. 核心语句: for line in f1: f1中的所有一行 f2.write(line) ...
- Java基础面试操作题:读取该文件内容,并按照自然顺序排序后输出到 另一个文件中
package com.swift; import java.io.FileInputStream; import java.io.FileNotFoundException; import java ...
- 代码实现:定义一个文件输入流,调用read(byte[] b)方法,将a.txt文件中的内容打印出来(byte数组大小限制为5)
package com.loaderman.test; import java.io.ByteArrayOutputStream; import java.io.FileInputStream; im ...
随机推荐
- Jetson TK1 五:移植工控机程序到板上
1.gazebo xml 2.王 chmod 777 chmod 777 /home/robot2/bzrobot_ws/src/bzrobot/bzrobot_control/bzrobot_con ...
- pandaboard用wifi时打不开网页
不可以手动修改/etc/resolv.conf,因为重启会被自动清空(raspberry pi 可以) 修改 resolvconf服务的配置文件: /etc/resolvconf/resolv.con ...
- yum gd linux
32位操作系统安装命令:[root@localhost ~]# yum install php-gd*64位操作系统安装命令:[root@localhost ~]# yum install php-g ...
- 【Todo】【读书笔记】Linux高性能服务器编程
在读 /Users/baidu/Documents/Data/Interview/服务器-检索端/<Linux高性能服务器编程.pdf> 其实之前读过,要面试了,需要温习. P260 So ...
- cocos2dx 3.0打包android遇到的错误(持续更新)
1.编译时遇到找不到文件的错误:比如fatal error: cocos-ext.h: No such file or directory , fatal error: CocosGUI.h: ...
- 系统去掉 Android 4.4.2 的StatusBar和NavigationBar
1. System Bar简单介绍 在Android4.0 (API Level 14)及更高版本号中.System Bar由Status Bar<位于顶部>和Navigation Bar ...
- Network Booting
http://en.wikipedia.org/wiki/Network_booting Network booting Network booting is the process of booti ...
- 利用ms17_010漏洞实验
1.理论 在MSF里面msfconsole可以说是最流行的一个接口程序.但是msfconsole真的是一个强大的接口程序.Msfconsole提供了一个一体化的集中控制台.通过msfconsole,你 ...
- router的安装和基本配置
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Array types are now written with the brackets around the element type问题的解决方法
在xcode6.1中来编写swift空数组时.出现的的这个问题,依照官方 Swift 教程<The Swift Programming Language>来写 let emptyArray ...