用文件名替换文件中的字符串值 [英] Replace string value in a file with filename

查看:95
本文介绍了用文件名替换文件中的字符串值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用文件名替换文件中的字符串。我有3000个文件具有不同的文件名。有什么方法我可以用批处理脚本我是完全新的脚本。请帮我这个



例如:我在文件中有一个文件名12345678.txt我有一些记录和一个字符串99999999.现在我想要用文件名12345678替换99999999



我在C中有文件:\ DATA \



我尝试了什么:



我对脚本完全不熟悉。请帮帮我

解决方案

使用PowerShell:

  


files = Get-ChildItem -path C:\ Data\ -filter * .txt
foreach


file

i want to replace the string in a file with file name. I am having 3000 files with different file names. Is there any way i can do with batch script I am completely new to scripting. please help me on this

eg: I am having a file name as 12345678.txt inside the file I am having some records along with a string 99999999. now i want to replace 99999999 with the file name 12345678.

I am having files in C:\DATA\

What I have tried:

I am completely new to scripting. please help me

解决方案

Using PowerShell:


files = Get-ChildItem -path C:\Data\ -filter *.txt foreach (


file in


这篇关于用文件名替换文件中的字符串值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆