当前位置: 首页 > news >正文

PowerShell 获取某目录下所有的文件、文件夹,同时对获取到的文件路径字符串进行替换处理

PowerShell 获取某目录下所有的文件、文件夹,同时对获取到的文件路径字符串进行替换处理


前言:

为了将Windows系统下的Java编译文件与linux服务器上的文件进行比较,故进行此文件路径的获取及路径处理。
在只有文件路径 而没有实际文件的情况下的比较。


代码如下:

## grep
#########################################
#检索文件夹所在路径
$findPath = "C:\wang\PowerShell\test\grep_cd_file\source"
#输出文件所在路径
$grepKekka = "C:\wang\PowerShell\test\grep_cd_file\grepKekka.csv"
$grepKekka1 = "C:\wang\PowerShell\test\grep_cd_file\grepKekka1.csv"
$grepKekka2 = "C:\wang\PowerShell\test\grep_cd_file\grepKekka2.csv"
# 清空输出文件
Clear-Content $grepKekka -Force
Clear-Content $grepKekka1 -Force
Clear-Content $grepKekka2 -Force# 替换 (\ : escape special characters)
$String1 = 'C:\\wang\\PowerShell\\test\\grep_cd_file\\source\\'
$String2 = '/wang/PowerShell/test/grep_cd_file/source/'# get the files exclude folders
$fileList = Get-ChildItem $findPath -Recurse * | where{!$_.PSIsContainer}
foreach($file in $fileList) {#print the file name$file.name | Out-File -Width 5000 -FilePath $grepKekka1 -Append# print the file fullname$file.fullname | Out-File -Width 5000 -FilePath $grepKekka2 -Append
}<#   replace多行注释
#>
(Get-Content $grepKekka2) -replace $String1, $String2 -replace '\\', '/' | Set-Content $grepKekka

输出文件(grepKekka.csv):

/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/day02_eesy_01mybatisCRUD.iml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/pom.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/.idea/.gitignore
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/.idea/compiler.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/.idea/jarRepositories.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/.idea/misc.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/.idea/workspace.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/java/com/itheima/dao/IUserDao.java
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/java/com/itheima/domain/QueryVo.java
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/java/com/itheima/domain/User.java
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/resources/jdbcConfig.properties
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/resources/log4j.properties
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/resources/SqlMapConfig.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/main/resources/com/itheima/dao/IUserDao.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/src/test/java/com/itheima/test/MybatisTest.java
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/jdbcConfig.properties
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/log4j.properties
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/SqlMapConfig.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/com/itheima/dao/IUserDao.class
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/com/itheima/dao/IUserDao.xml
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/com/itheima/domain/QueryVo.class
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/classes/com/itheima/domain/User.class
/wang/PowerShell/test/grep_cd_file/source/day02_eesy_01mybatisCRUD/target/test-classes/com/itheima/test/MybatisTest.class

输出文件(grepKekka1.csv):

day02_eesy_01mybatisCRUD.iml
pom.xml
.gitignore
compiler.xml
jarRepositories.xml
misc.xml
workspace.xml
IUserDao.java
QueryVo.java
User.java
jdbcConfig.properties
log4j.properties
SqlMapConfig.xml
IUserDao.xml
MybatisTest.java
jdbcConfig.properties
log4j.properties
SqlMapConfig.xml
IUserDao.class
IUserDao.xml
QueryVo.class
User.class
MybatisTest.class

输出文件(grepKekka2.csv):

C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\day02_eesy_01mybatisCRUD.iml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\pom.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\.idea\.gitignore
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\.idea\compiler.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\.idea\jarRepositories.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\.idea\misc.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\.idea\workspace.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\java\com\itheima\dao\IUserDao.java
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\java\com\itheima\domain\QueryVo.java
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\java\com\itheima\domain\User.java
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\resources\jdbcConfig.properties
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\resources\log4j.properties
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\resources\SqlMapConfig.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\main\resources\com\itheima\dao\IUserDao.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\src\test\java\com\itheima\test\MybatisTest.java
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\jdbcConfig.properties
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\log4j.properties
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\SqlMapConfig.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\com\itheima\dao\IUserDao.class
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\com\itheima\dao\IUserDao.xml
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\com\itheima\domain\QueryVo.class
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\classes\com\itheima\domain\User.class
C:\wang\PowerShell\test\grep_cd_file\source\day02_eesy_01mybatisCRUD\target\test-classes\com\itheima\test\MybatisTest.class

结语:

为了将Windows系统下的Java编译文件与linux服务器上的文件进行比较,故进行此文件路径的获取及路径处理。
在只有文件路径 而没有实际文件的情况下的比较。


相关文章:

PowerShell 获取某目录下所有的文件、文件夹,同时对获取到的文件路径字符串进行替换处理

PowerShell 获取某目录下所有的文件、文件夹&#xff0c;同时对获取到的文件路径字符串进行替换处理 前言&#xff1a; 为了将Windows系统下的Java编译文件与linux服务器上的文件进行比较&#xff0c;故进行此文件路径的获取及路径处理。 在只有文件路径 而没有实际文件的情况下…...

JUC并发编程之线程锁(一)

目录 1.ReentrantLock(互斥锁) 2.ReentRantReaderWriterLock&#xff08;互斥读写锁&#xff09; 3.StampedLock&#xff08;无障碍锁&#xff09; 4.Condition&#xff08;自定义锁&#xff09; 5.LockSupport 问题引出&#xff1a; 由于传统的线程控制需要用到同步机制Sy…...

Android AlertDialog标题居中

网上很多做法都是使用setCustomTitle方法实现的&#xff0c;我偏不&#xff0c;因为我已经找到了标题的textView了&#xff1a; 在show了之后可以拿到标题&#xff08;注意一定是show之后才能拿得到&#xff0c;create之后拿也是空的&#xff09;&#xff1a; TextView title…...

k8s界面化平台dashboard、kubesphere、Rancher对比

k8s集群管理dashboard有很多&#xff0c;比如kuboard、官方发dashboard、kubesphere、Rancher等等。 Dashboard、KubeSphere 和 Rancher 都是流行的 Kubernetes 管理和操作界面。它们都提供了图形化的用户界面&#xff0c;以简化对 Kubernetes 集群的管理和监控。每个工具都有其…...

【字符串左旋】

字符串左旋 1.题目要求 实现一个函数&#xff0c;可以左旋字符串中的k个字符。 例如&#xff1a; ABCD左旋一个字符得到BCDA ABCD左旋两个字符得到CDAB 2.解法&#xff1a; 设计循环使其可以旋1次&#xff0c;然后让他执行n次是一个最简单的思路&#xff1a; 函数实现&#xf…...

Docker Dirtypipe(CVE-2022-0847)漏洞复现与分析容器逃逸

安装环境 ./metarget cnv install cve-2022-0847 --verbose 原理 同脏牛&#xff0c;通过写只读内存&#xff0c;对映射的内存做篡改 EXP docker run --rm -it -v $(pwd):/exp --cap-addCAP_DAC_READ_SEARCH ubuntu如果提示 Unknown capability to add: "CAP_CAP_DAC_RE…...

python接口自动化测试框架2.0,让你像Postman一样编写测试用例,支持多环境切换、多业务依赖、数据库断言等

项目介绍 接口自动化测试项目2.0 软件架构 本框架主要是基于 Python unittest ddt HTMLTestRunner log excel mysql 企业微信通知 Jenkins 实现的接口自动化框架。 前言 公司突然要求你做自动化&#xff0c;但是没有代码基础不知道怎么做&#xff1f;或者有自动化…...

Vue.js2+Cesium1.103.0 九、淹没分析效果

Vue.js2Cesium1.103.0 九、淹没分析效果 Demo <template><divid"cesium-container"style"width: 100%; height: 100%;"><spanid"button"style"position: absolute; right: 50px; top: 50px; z-index: 999; font-size: 24px…...

SpringBoot案例-部门管理-新增

根据页面原型&#xff0c;明确需求 页面原型 需求 阅读接口文档 接口文档链接如下&#xff1a; 【腾讯文档】SpringBoot案例所需文档 https://docs.qq.com/doc/DUkRiTWVaUmFVck9N 思路分析 前端在输入要新增的部门名称后&#xff0c;会以JSON格式将数据传入至后端&#xf…...

微信小程序中背景图片如何占满整个屏幕,拉伸

不变形 1. 在页面的wxss文件中&#xff0c;设置背景图片的样式&#xff1a; page{background-image: url(图片路径);background-size: 100% 100%;background-repeat: no-repeat; }2. 在页面的json文件中&#xff0c;设置背景图片的样式&#xff1a; {"backgroundTextStyl…...

Java并发编程(四)线程同步 中 [AQS/Lock]

概述 Java中可以通过加锁&#xff0c;来保证多个线程访问某一个公共资源时&#xff0c;资源的访问安全性。Java提出了两种方式来加锁 第一种是我们上文提到的通过关键字synchronized加锁&#xff0c;synchronized底层托管给JVM执行的&#xff0c;并且在java 1.6 以后做了很多…...

PyTorch深度学习环境安装(Anaconda、CUDA、cuDNN)及关联PyCharm

1. 关系讲解 Tytorch&#xff1a;Python机器学习库&#xff0c;基于Torch&#xff0c;用于自然语言处理等应用程序 Anaconda&#xff1a;是默认的python包和环境管理工具&#xff0c;安装了anaconda&#xff0c;就默认安装了conda CUDA&#xff1a;CUDA是一种由显卡厂商NVIDI…...

Active Directory安全和风险状况管理

风险评估和管理 风险评估和管理是主动安全性和合规性管理不可或缺的一部分。 发现关键基础设施组件中的风险行为和配置对于阻止网络入侵和预防网络攻击至关重要。帐户泄露和配置错误漏洞是用于破坏网络的常见技术。当评估、监控和降低 Active Directory 基础架构的风险时&…...

学术论文GPT源码解读:从chatpaper、chatwithpaper到gpt_academic

前言 之前7月中旬&#xff0c;我曾在微博上说准备做“20个LLM大型项目的源码解读” 针对这个事&#xff0c;目前的最新情况是 已经做了的&#xff1a;LLaMA、Alpaca、ChatGLM-6B、deepspeedchat、transformer、langchain、langchain-chatglm知识库准备做的&#xff1a;chatpa…...

单链表(C语言版)

单链表&#xff1a;理解、实现与应用 单链表&#xff08;Singly Linked List&#xff09;是一种常见的数据结构&#xff0c;用于存储一系列具有相同类型的元素&#xff0c;并通过节点之间的链接建立起它们的关系。每个节点包含一个数据元素和一个指向下一个节点的指针。相比于…...

初学vue3时应该注意的几个问题

初学vue3时应该注意的几个问题 声明响应式 响应式数据的声明在vue2的时候很简单&#xff0c;在data中声明就行了。但现在可以使用多个方式。 reactive用于声明Object, Array, Map, Set; ref用于声明String, Number, Boolean 使用reactive来声明基础数据类型&#xff08;Str…...

基于Selenium技术方案的爬虫入门实践

通过爬虫技术抓取网页&#xff0c;动态加载的数据或包含 JavaScript 的页面&#xff0c;需要使用一些特殊的技术和工具。以下是一些常用的技术方法&#xff1a; 使用浏览器模拟器&#xff1a;使用像 Selenium、PhantomJS 或其他类似工具可以模拟一个完整的浏览器环境&#xff0…...

【C++入门到精通】C++入门 —— vector (STL)

阅读导航 前言一、vector简介1. 概念2. 特点 二、vector的使用1.vector 构造函数2. vector 空间增长问题⭕resize 和 reserve 函数 3. vector 增删查改⭕operator[] 函数 三、迭代器失效温馨提示 前言 前面我们讲了C语言的基础知识&#xff0c;也了解了一些数据结构&#xff0…...

git简单使用

1.在 远端仓库创建好仓库 2.在本地中创建仓库 ​ mkdir 仓库名 ​ cd 仓库名 3.初始化(可以省略) ​ git init 4.添加远端仓库 ​ git remote add origin https://gitee.com/zengtian_7/pet_home.git 5.初始化代码库&#xff1a;当你创建一个全新的代码库时&#xff0c…...

CSS—选择器

目录 一、CSS简介 二、HTML页面中常用的元素 三、CSS语法规则 四、常用的选择器 五、CSS的三种使用方法 六、选择器参考 一、CSS简介 CSS (Cascading Style Sheets&#xff0c;层叠样式表&#xff09;&#xff0c;是一种用来为结构化文档&#xff08;如 HTML 文档或 XML 应…...

树莓派超全系列教程文档--(62)使用rpicam-app通过网络流式传输视频

使用rpicam-app通过网络流式传输视频 使用 rpicam-app 通过网络流式传输视频UDPTCPRTSPlibavGStreamerRTPlibcamerasrc GStreamer 元素 文章来源&#xff1a; http://raspberry.dns8844.cn/documentation 原文网址 使用 rpicam-app 通过网络流式传输视频 本节介绍来自 rpica…...

rknn优化教程(二)

文章目录 1. 前述2. 三方库的封装2.1 xrepo中的库2.2 xrepo之外的库2.2.1 opencv2.2.2 rknnrt2.2.3 spdlog 3. rknn_engine库 1. 前述 OK&#xff0c;开始写第二篇的内容了。这篇博客主要能写一下&#xff1a; 如何给一些三方库按照xmake方式进行封装&#xff0c;供调用如何按…...

Cinnamon修改面板小工具图标

Cinnamon开始菜单-CSDN博客 设置模块都是做好的&#xff0c;比GNOME简单得多&#xff01; 在 applet.js 里增加 const Settings imports.ui.settings;this.settings new Settings.AppletSettings(this, HTYMenusonichy, instance_id); this.settings.bind(menu-icon, menu…...

拉力测试cuda pytorch 把 4070显卡拉满

import torch import timedef stress_test_gpu(matrix_size16384, duration300):"""对GPU进行压力测试&#xff0c;通过持续的矩阵乘法来最大化GPU利用率参数:matrix_size: 矩阵维度大小&#xff0c;增大可提高计算复杂度duration: 测试持续时间&#xff08;秒&…...

如何在网页里填写 PDF 表格?

有时候&#xff0c;你可能希望用户能在你的网站上填写 PDF 表单。然而&#xff0c;这件事并不简单&#xff0c;因为 PDF 并不是一种原生的网页格式。虽然浏览器可以显示 PDF 文件&#xff0c;但原生并不支持编辑或填写它们。更糟的是&#xff0c;如果你想收集表单数据&#xff…...

算法岗面试经验分享-大模型篇

文章目录 A 基础语言模型A.1 TransformerA.2 Bert B 大语言模型结构B.1 GPTB.2 LLamaB.3 ChatGLMB.4 Qwen C 大语言模型微调C.1 Fine-tuningC.2 Adapter-tuningC.3 Prefix-tuningC.4 P-tuningC.5 LoRA A 基础语言模型 A.1 Transformer &#xff08;1&#xff09;资源 论文&a…...

20个超级好用的 CSS 动画库

分享 20 个最佳 CSS 动画库。 它们中的大多数将生成纯 CSS 代码&#xff0c;而不需要任何外部库。 1.Animate.css 一个开箱即用型的跨浏览器动画库&#xff0c;可供你在项目中使用。 2.Magic Animations CSS3 一组简单的动画&#xff0c;可以包含在你的网页或应用项目中。 3.An…...

【堆垛策略】设计方法

堆垛策略的设计是积木堆叠系统的核心&#xff0c;直接影响堆叠的稳定性、效率和容错能力。以下是分层次的堆垛策略设计方法&#xff0c;涵盖基础规则、优化算法和容错机制&#xff1a; 1. 基础堆垛规则 (1) 物理稳定性优先 重心原则&#xff1a; 大尺寸/重量积木在下&#xf…...

针对药品仓库的效期管理问题,如何利用WMS系统“破局”

案例&#xff1a; 某医药分销企业&#xff0c;主要经营各类药品的批发与零售。由于药品的特殊性&#xff0c;效期管理至关重要&#xff0c;但该企业一直面临效期问题的困扰。在未使用WMS系统之前&#xff0c;其药品入库、存储、出库等环节的效期管理主要依赖人工记录与检查。库…...

机器学习的数学基础:线性模型

线性模型 线性模型的基本形式为&#xff1a; f ( x ) ω T x b f\left(\boldsymbol{x}\right)\boldsymbol{\omega}^\text{T}\boldsymbol{x}b f(x)ωTxb 回归问题 利用最小二乘法&#xff0c;得到 ω \boldsymbol{\omega} ω和 b b b的参数估计$ \boldsymbol{\hat{\omega}}…...