Last active
December 9, 2015 22:48
-
-
Save kameit00/4339863 to your computer and use it in GitHub Desktop.
Fast hack to find duplicate files on my dreambox.
Files are named like ...DATE - CHANNEL - NAME.ts
To find duplicates, only NAME should be compared.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.apache.commons.vfs2.VFS | |
import org.apache.commons.vfs2.provider.ftp.FtpFileObject | |
import java.util.regex.Pattern | |
def fsManager = VFS.manager | |
def movieDir = fsManager.resolveFile("ftp://root:[email protected]/media/USB2.0Drive") | |
def set = new HashSet<String>() | |
movieDir.children.each { FtpFileObject item -> | |
if (item.name.toString().endsWith(".ts")) { | |
def pattern = Pattern.compile("(.*)( - )(.*)(.ts)") | |
def matcher = pattern.matcher(item.name.toString()) | |
if (matcher.matches()) { | |
if (!set.add(matcher.group(3).toString())) { | |
println matcher.group(3).toString() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment