@@ -100,24 +100,25 @@ def identify_and_update_file(path, keep_name, uselib):
100
100
song .tags ["TITLE" ] = [title ]
101
101
song .save ()
102
102
103
- newpath = path
103
+ olddir , oldfile = os .path .split (path )
104
+ oldfile , oldext = os .path .splitext (path )
105
+ newbase = olddir + "/" + cleanstr (artist , 100 ) + "-" + cleanstr (title , 100 )
104
106
if not keep_name :
105
- olddir , oldfile = os .path .split (path )
106
- oldfile , oldext = os .path .splitext (path )
107
- newbase = olddir + "/" + cleanstr (artist , 100 ) + "-" + cleanstr (title , 100 )
108
107
newpath = newbase + oldext
109
- cnt = 0
110
- while os .path .isfile (newpath ):
111
- if cnt > 1000 :
112
- print ("FAIL : max number of conflicting file names reached" )
113
- return False
108
+ if newpath != path :
109
+ cnt = 0
110
+ while os .path .isfile (newpath ):
111
+ if cnt > 1000 :
112
+ print ("FAIL : max number of conflicting file names reached" )
113
+ return False
114
114
115
- cnt = cnt + 1
116
- newpath = newbase + "_" + str (cnt ) + oldext
115
+ cnt = cnt + 1
116
+ newpath = newbase + "_" + str (cnt ) + oldext
117
117
118
- os .rename (path , newpath )
118
+ os .rename (path , newpath )
119
+ path = newpath
119
120
120
- print ("OK : " + newpath )
121
+ print ("OK : " + path )
121
122
return True
122
123
123
124
@@ -142,7 +143,7 @@ def main():
142
143
"Artist_Name-Track_Name." )
143
144
parser .add_argument ("-k" , "--keepname" , action = "store_true" , help = "keep original filename" )
144
145
parser .add_argument ("-l" , "--uselib" , action = "store_true" , help = "use chromaprint lib instead of tools" )
145
- parser .add_argument ("-v" , "--version" , action = 'version' , version = '%(prog)s v1.10 ' )
146
+ parser .add_argument ("-v" , "--version" , action = 'version' , version = '%(prog)s v1.11 ' )
146
147
parser .add_argument ('path' , nargs = '+' , help = 'path of a file or directory' )
147
148
args = parser .parse_args ()
148
149
0 commit comments