5 from optparse
import OptionParser
6 from tag_wrapper
import tag
8 ACCEPTEXTS
= [".ogg"] # Keep it simple for now
10 def issupportedfile(name
):
11 for ext
in ACCEPTEXTS
:
12 if os
.path
.splitext(name
)[1] == ext
:
16 def newpath(file, target
, pattern
):
17 # Create the tokens dictionary
20 # TODO: add tracknumber, disknumber and possibily compilation
21 for t
in ["title", "artist", "album artist", "album", "composer", "genre", "date"]:
26 # %album artist% is %artist% if nothing can be found in the tags
27 if tokens
["album artist"] == None:
28 tokens
["album artist"] = tokens
["artist"]
30 # That appears in no tag
31 tokens
["base"] = target
35 parser
= OptionParser()
36 parser
.add_option("-r", "--recursive", action
="store_true",
37 parser
.add_option("-t", "--target", dest
="targetpath", metavar
="TARGET",
38 dest
="recursive", default
=False)
39 help="create new directory structure in directory TARGET (default=directory)") #TODO: not implemented
40 (options
, args
) = parser
.parse_args()
45 print "You must specify a directory"
50 walkme
= basepath
.walkfiles()
52 walkme
= basepath
.files()
53 for filepath
in walkme
:
54 if issupportedfile(filepath
):
57 if __name__
== "__main__":