Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / sw / RenameFilesInDirectoryByXpathElementContentTrace.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

    
24
import org.txm.importer.*
25

    
26
// parameters
27
                                                                                                        // **change this parameter**
28
dir = new File(System.getProperty("user.home"), "TXM/sources/Factiva")
29
                                                                                                        // **change this parameter**
30
xpath = "/article/@date"
31

    
32
print "Renaming"
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
        print "."
37
}
38
println "Done."