Merge pull request #1811 from piejanssens/Begall-renamer-origfolder

Add $OriginalFolder flag to renamer (thx Begall)
This commit is contained in:
Pieter Janssens
2014-08-11 20:38:15 +02:00
2 changed files with 10 additions and 3 deletions

View File

@@ -948,7 +948,7 @@
<div class="row">
<label>Folder Format</label>
<input type="text" name="folder_format" value="${config['folder_format']}" size="43">
<small>Use: $Artist/$artist, $Album/$album, $Year/$year, $Type/$type (release type) and $First/$first (first letter in artist name)
<small>Use: $Artist/$artist, $Album/$album, $Year/$year, $Type/$type (release type) and $First/$first (first letter in artist name), $OriginalFolder/$originalfolder (downloaded directory name)
E.g.: $Type/$First/$artist/$album [$year] = Album/G/girl talk/all day [2010]</small>
</div>

View File

@@ -622,20 +622,27 @@ def moveFiles(albumpath, release, tracks):
firstchar = '0-9'
else:
firstchar = sortname[0]
for r,d,f in os.walk(albumpath):
try:
origfolder = os.path.basename(os.path.normpath(r))
except:
origfolder = ''
values = { '$Artist': artist,
'$SortArtist': sortname,
'$Album': album,
'$Year': year,
'$Type': releasetype,
'$OriginalFolder': origfolder,
'$First': firstchar.upper(),
'$artist': artist.lower(),
'$sortartist': sortname.lower(),
'$album': album.lower(),
'$year': year,
'$type': releasetype.lower(),
'$first': firstchar.lower()
'$first': firstchar.lower(),
'$originalfolder': origfolder.lower()
}
folder = helpers.replace_all(headphones.FOLDER_FORMAT.strip(), values)