| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 760 人关注过本帖
标题:我出一个题目 关于文件处理的偏实际应用的 不限语言
只看楼主 加入收藏
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
结帖率:100%
收藏
已结贴  问题点数:100 回复次数:3 
我出一个题目 关于文件处理的偏实际应用的 不限语言
要求

处理Sumatra PDF的配置文件 删除其中不存在文件的缓存数据 例子文件如下
# For documentation, see http://blog.kowalczyk.info/software/sumatrapdf/settings3.0.html

MainWindowBackground = #80fff200
EscToExit = false
ReuseInstance = false
UseSysColors = false

FixedPageUI [
    TextColor = #000000
    BackgroundColor = #ffffff
    SelectionColor = #f5fc0c
    WindowMargin = 2 4 2 4
    PageSpacing = 4 4
]
EbookUI [
    FontName = Georgia
    FontSize = 12.5
    TextColor = #5f4b32
    BackgroundColor = #fbf0d9
    UseFixedPageUI = false
]
ComicBookUI [
    WindowMargin = 0 0 0 0
    PageSpacing = 4 4
    CbxMangaMode = false
]
ChmUI [
    UseFixedPageUI = false
]
ExternalViewers [
]
ShowMenubar = true
ReloadModifiedDocuments = true
FullPathInTitle = false
ZoomLevels = 8.33 12.5 18 25 33.33 50 66.67 75 100 125 150 200 300 400 600 800 1000 1200 1600 2000 2400 3200 4800 6400
ZoomIncrement = 0

PrinterDefaults [
    PrintScale = shrink
    PrintAsImage = false
]
ForwardSearch [
    HighlightOffset = 0
    HighlightWidth = 15
    HighlightColor = #6581ff
    HighlightPermanent = false
]
CustomScreenDPI = 0

RememberStatePerDocument = true
UiLanguage = cn
ShowToolbar = true
ShowFavorites = false
AssociateSilently = false
CheckForUpdates = true
RememberOpenedFiles = true
EnableTeXEnhancements = false
DefaultDisplayMode = automatic
DefaultZoom = fit page
WindowState = 2
WindowPos = 560 0 799 1034
ShowToc = true
SidebarDx = 483
TocDy = 0
ShowStartPage = true
UseTabs = true

FileStates [
    [
        FilePath = Z:\论道德建设的实践性原则_杜杰.pdf
        Favorites [
        ]
        IsPinned = false
        IsMissing = false
        OpenCount = 0
        UseDefaultState = false
        DisplayMode = continuous
        ScrollPos = -1 182
        PageNo = 2
        Zoom = 200
        Rotation = 0
        WindowState = 2
        WindowPos = 560 0 799 1034
        ShowToc = false
        SidebarDx = 483
        DisplayR2L = false
        ReparseIdx = 0
    ]
    [
        FilePath = Z:\1-s2.0-096808969500053J-main.pdf
        Favorites [
        ]
        IsPinned = false
        IsMissing = false
        OpenCount = 1
        UseDefaultState = false
        DisplayMode = continuous
        ScrollPos = -1 414
        PageNo = 1
        Zoom = 200
        Rotation = 0
        WindowState = 2
        WindowPos = 560 0 799 1034
        ShowToc = false
        SidebarDx = 483
        DisplayR2L = false
        ReparseIdx = 0
        TocState = 2 5 6 7 8 9 10 12 13 14 15 16 17 18 19 20 21 23 24 25 27 28 30 31 32 33 34 35 36 37 38 39 40
    ]
]
TimeOfLastUpdateCheck = 30414503 -647654859
OpenCountWeek = 206


比如第一个文件已经不存在的 则在新文件里面将
    [
        FilePath = Z:\论道德建设的实践性原则_杜杰.pdf
        Favorites [
...
    ]


这些全部删除 生成一个新的文件

我用Emacs Lisp写了一个 想看看各位如何实现的

程序代码:
(with-temp-buffer
  (insert-file-contents "Z:/a.txt")
  (while (re-search-forward "^.*FilePath = \\(.*\\.pdf\\)$" nil t)
    (let ((filename
       (replace-regexp-in-string "\\\\"
                     "/" (match-string 1) t t))
      (p1)
      (p2))
      (unless (file-exists-p filename)
    (beginning-of-line)
    (previous-line)
    (setq p1 (point))
    (forward-sexp)
    (setq p2 (point))
    (delete-region p1 p2)
    (kill-line)
    ))
    )
  (write-file "Z:/output.txt"))

搜索更多相关主题的帖子: 实际应用 配置文件 ffffff 
2014-12-13 18:54
wp231957
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:神界
等 级:贵宾
威 望:423
帖 子:13688
专家分:53332
注 册:2012-10-18
收藏
得分:50 
完全不懂

DO IT YOURSELF !
2014-12-13 22:26
TonyDeng
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:贵宾
威 望:304
帖 子:25859
专家分:48889
注 册:2011-6-22
收藏
得分:50 
我给烛林小煜写的那个程序,就是这一类的处理。

授人以渔,不授人以鱼。
2014-12-13 22:32
zklhp
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
来 自:china
等 级:贵宾
威 望:254
帖 子:11485
专家分:33241
注 册:2007-7-10
收藏
得分:0 
没人感兴趣 没意思
2014-12-14 15:28
快速回复:我出一个题目 关于文件处理的偏实际应用的 不限语言
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017450 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved