/// <inheritdoc /> public void Organize(MediaFile media) { // trasnform moviePath var originalPath = media.FullPath; var moviePath = TransformPath(media); // target var targetDir = Path.GetDirectoryName(moviePath); Trace.Assert(targetDir != null); Directory.CreateDirectory(targetDir); // apply moviePath transformation var subtitlePath = Path.Combine(targetDir, Path.GetFileName(media.SubtitlePath)); var posterPath = Path.Combine(targetDir, Path.GetFileName(media.PosterPath)); // move movie, sub, poster File.Move(media.FullPath, moviePath); File.Move(media.SubtitlePath, subtitlePath); File.Move(media.PosterPath, posterPath); // update db UpdateMediaFile(moviePath, subtitlePath, posterPath, media); // clean empty dir if (DeleteEmptyDirectories) { _cleaner.Clean(Path.GetDirectoryName(originalPath)); } Log.InfoFormat("Media organized: {0} ==> {1}", originalPath, moviePath); }
private void DoCleanFolder(string folder, TimeSpan timeSpan) { var cleanupExceptions = _folderCleaner.Clean(folder, timeSpan); foreach (var pathExceptionPair in cleanupExceptions) { _logger.Debug($"Exception while cleaning up {pathExceptionPair.Key}: {pathExceptionPair.Value}"); } }