Notepad ++查找包含xxxxxx / Reports / reportname.pdf的所有行,并替换为xxxxxx / Reports / PDF / reportname.pdf

时间:2022-11-13 19:14:52

Screenshot of the fileI have a file which contains multiple lines

fileI的屏幕截图有一个包含多行的文件

Source Path                       Target Path

xxxx/out/reportname1.pdf         xxxx/out/Reports/reportname1.pdf
xxxx/out/reportname2.txt         xxxx/out/Reports/reportname2.txt
xxxx/out/reportname3.csv         xxxx/out/Reports/reportname2.csv

I would like to replace /Reports/reportname1.pdf to /PDFReports/reportname1.pdf for only PDF files.

我想将/Reports/reportname1.pdf替换为/PDFReports/reportname1.pdf,仅用于PDF文件。

Please suggest I tried using /Reports/.*pdf and I am able to find it, but unable to replace it

请建议我尝试使用/Reports/.*pdf并且我能够找到它,但无法替换它

3 个解决方案

#1


1  

Search for \/Reports\/(.*?\.pdf) and replace with /PDFReports/$1

搜索\ / Reports \ /(。*?\。pdf)并替换为/ PDFReports / $ 1

#2


1  

You would need to use replacing with regex syntax (ctrl+H by default)

您需要使用regex语法替换(默认情况下为ctrl + H)

Try something like:

尝试以下方法:

Find what:

\/Reports\/(.*\.pdf)

Replace with:

/PDFReports/$1

And use "regular expression" search mode.

并使用“正则表达式”搜索模式。

This mechanism is called capture group - braces in "Find what" are used to remember the content inside them and then this content is references later by $1.

这种机制称为捕获组 - “查找内容”中的大括号用于记住其中的内容,然后此内容稍后引用$ 1。

Note - you might have to use "\1" instead of "$1" in case of old version of Np++

注意 - 对于旧版本的Np ++,您可能必须使用“\ 1”而不是“$ 1”

#3


0  

searching pattern: ([\w\_]+\.\w+)

搜索模式:([\ w \ _] + \。\ w +)

replace to: Reports/$1

替换为:Reports / $ 1

output:

xxxx/out/Reports/reportname1.pdf
xxxx/out/Reports/reportname2.txt
xxxx/out/Reports/reportname3.csv

EDIT: since filenames could containt _, little upgrade.

编辑:因为文件名可能包含_,几乎没有升级。

#1


1  

Search for \/Reports\/(.*?\.pdf) and replace with /PDFReports/$1

搜索\ / Reports \ /(。*?\。pdf)并替换为/ PDFReports / $ 1

#2


1  

You would need to use replacing with regex syntax (ctrl+H by default)

您需要使用regex语法替换(默认情况下为ctrl + H)

Try something like:

尝试以下方法:

Find what:

\/Reports\/(.*\.pdf)

Replace with:

/PDFReports/$1

And use "regular expression" search mode.

并使用“正则表达式”搜索模式。

This mechanism is called capture group - braces in "Find what" are used to remember the content inside them and then this content is references later by $1.

这种机制称为捕获组 - “查找内容”中的大括号用于记住其中的内容,然后此内容稍后引用$ 1。

Note - you might have to use "\1" instead of "$1" in case of old version of Np++

注意 - 对于旧版本的Np ++,您可能必须使用“\ 1”而不是“$ 1”

#3


0  

searching pattern: ([\w\_]+\.\w+)

搜索模式:([\ w \ _] + \。\ w +)

replace to: Reports/$1

替换为:Reports / $ 1

output:

xxxx/out/Reports/reportname1.pdf
xxxx/out/Reports/reportname2.txt
xxxx/out/Reports/reportname3.csv

EDIT: since filenames could containt _, little upgrade.

编辑:因为文件名可能包含_,几乎没有升级。