[英]Compare and Delete in txt files
我想要一些脚本或程序来比较文本文档,并在两个文本中找到相同的电子邮件地址并创建一个新文件,其中仅出现在两个文件之一中的电子邮件地址被保留(两个文件中出现的电子邮件地址已被删除)在这个新的文本文件中)。
我尝试了各种比较程序,但是它们考虑了位置和字体等,等等。我的程序不足以更改设置(如果可能的话)。 也许在Applescript中? 我使用Mac ...
例
Text1:
a@mail.x
b@mail.x
c@mail.x
e@mail.x
a@mail.x <--(yes, that's a duplicate... I would like to have them deleted as well)
Text2:
b@mail.x
c@mail.x
a@mail.x
d@mail.x
Text3:
d@mail.x
e@mail.x
尝试:
set compareDocs to choose file with prompt "Select files to compare" with multiple selections allowed
set uniqueItems to {}
repeat with aDoc in compareDocs
set addresses to paragraphs of (read aDoc as «class utf8»)
repeat with address in addresses
set address to contents of address
if address is not in uniqueItems then
set end of uniqueItems to address
set end of uniqueItems to linefeed
end if
end repeat
end repeat
set parentFolder to POSIX path of ((first item of compareDocs as text) & "::")
set parentFolder to parentFolder & "Unique_Addresses.txt"
set uniqueItems to uniqueItems as text
do shell script "echo " & quoted form of uniqueItems & " > " & quoted form of parentFolder
在Excel(删除重复项)中找到了一种满足我需要的方法。
不管怎么说,还是要谢谢你!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.