Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / sw / RenameFilesInDirectoryByXpathElementContent.groovy @ 479

History | View | Annotate | Download (1.3 kB)

1
package org.txm.sw
2
// Copyright © - ENS de Lyon - http://textometrie.ens-lyon.fr
3
//
4
// This file is part of the TXM platform.
5
//
6
// The TXM platform is free software: you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation, either version 3 of the License, or
9
// (at your option) any later version.
10
//
11
// The TXM platform is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License
17
// along with the TXM platform.  If not, see <http://www.gnu.org/licenses/>.
18
//
19
// $LastChangedDate: 2013-05-02 10:05:14 +0200 (jeu. 02 mai 2013) $
20
// $LastChangedRevision: 2377 $
21
// $LastChangedBy: sheiden $
22
//
23
import org.txm.importer.*
24

    
25
// parameters
26

    
27
// **change this parameter**
28
dir = new File(System.getProperty("user.home"), "TXM/sources/Factiva")
29

    
30
// **change this parameter**
31
xpath = "/article/@date"
32

    
33
// main body
34
dir.eachFileMatch(~/.*.xml/){ file -> // for each file
35
        file.renameTo(new File(file.getParent(), XPathResult.getXpathResponse(file, xpath)+"_"+file.name));
36
}