All are Windows *.lnk files!
This commit is contained in:
parent
6909146d90
commit
1355cd0241
@ -297,8 +297,7 @@ public partial class DlibDotNet
|
|||||||
configurationOutputResolutionsHas = true;
|
configurationOutputResolutionsHas = true;
|
||||||
if (!runToDoCollectionFirst)
|
if (!runToDoCollectionFirst)
|
||||||
break;
|
break;
|
||||||
(filesCollectionRootDirectory, filesCollection) = GetFilesCollectionThenCopyOrMove(ticks, fileSearchFilter, directorySearchFilter, options, outputResolution);
|
(filesCollectionRootDirectory, filesCollection, filesCollectionCountIsOne) = GetFilesCollectionThenCopyOrMove(ticks, fileSearchFilter, directorySearchFilter, options, outputResolution);
|
||||||
filesCollectionCountIsOne = filesCollection.Count == 1;
|
|
||||||
notNineCollection = GetNotNineCollection(filesCollection);
|
notNineCollection = GetNotNineCollection(filesCollection);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -416,41 +415,57 @@ public partial class DlibDotNet
|
|||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
string[] directories;
|
string[] directories;
|
||||||
string seasonDirectory;
|
directories = Directory.GetDirectories(_Configuration.PropertyConfiguration.RootDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
DirectoryInfo directoryInfo;
|
if (directories.Length == 0)
|
||||||
DateTime dateTime = new(ticks);
|
result = true;
|
||||||
string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
else
|
||||||
string eDistanceContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(E_Distance), _Configuration.PropertyConfiguration.ResultContent);
|
{
|
||||||
(int season, string seasonName) = Shared.Models.Stateless.Methods.IProperty.GetSeason(dateTime.DayOfYear);
|
string seasonDirectory;
|
||||||
FileSystemInfo fileSystemInfo = new DirectoryInfo(eDistanceContentDirectory);
|
DirectoryInfo directoryInfo;
|
||||||
string[] checkDirectories =
|
DateTime dateTime = new(ticks);
|
||||||
[
|
string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||||
Path.Combine(rootDirectory, "Ancestry"),
|
string eDistanceContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(E_Distance), _Configuration.PropertyConfiguration.ResultContent);
|
||||||
|
(int season, string seasonName) = Shared.Models.Stateless.Methods.IProperty.GetSeason(dateTime.DayOfYear);
|
||||||
|
FileSystemInfo fileSystemInfo = new DirectoryInfo(eDistanceContentDirectory);
|
||||||
|
string[] checkDirectories =
|
||||||
|
[
|
||||||
|
Path.Combine(rootDirectory, "Ancestry"),
|
||||||
Path.Combine(rootDirectory, "Facebook"),
|
Path.Combine(rootDirectory, "Facebook"),
|
||||||
Path.Combine(rootDirectory, "LinkedIn"),
|
Path.Combine(rootDirectory, "LinkedIn"),
|
||||||
rootDirectory,
|
rootDirectory,
|
||||||
];
|
];
|
||||||
foreach (string checkDirectory in checkDirectories)
|
foreach (string checkDirectory in checkDirectories)
|
||||||
{
|
|
||||||
if (checkDirectory == rootDirectory)
|
|
||||||
seasonDirectory = Path.Combine(checkDirectory, $"{dateTime.Year}.{season} {seasonName}");
|
|
||||||
else
|
|
||||||
seasonDirectory = Path.Combine(checkDirectory, $"{dateTime.Year}.{season} {seasonName} {Path.GetFileName(checkDirectory)}");
|
|
||||||
if (!Directory.Exists(seasonDirectory))
|
|
||||||
_ = Directory.CreateDirectory(seasonDirectory);
|
|
||||||
if (result)
|
|
||||||
continue;
|
|
||||||
directories = Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
||||||
foreach (string directory in directories)
|
|
||||||
{
|
{
|
||||||
directoryInfo = new(directory);
|
if (checkDirectory == rootDirectory)
|
||||||
if (directoryInfo.LastWriteTime > fileSystemInfo.LastWriteTime)
|
seasonDirectory = Path.Combine(checkDirectory, $"{dateTime.Year}.{season} {seasonName}");
|
||||||
|
else
|
||||||
|
seasonDirectory = Path.Combine(checkDirectory, $"{dateTime.Year}.{season} {seasonName} {Path.GetFileName(checkDirectory)}");
|
||||||
|
if (!Directory.Exists(seasonDirectory))
|
||||||
|
_ = Directory.CreateDirectory(seasonDirectory);
|
||||||
|
if (result)
|
||||||
|
continue;
|
||||||
|
directories = Directory.GetDirectories(checkDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string directory in directories)
|
||||||
{
|
{
|
||||||
result = true;
|
directoryInfo = new(directory);
|
||||||
break;
|
if (directoryInfo.LastWriteTime > fileSystemInfo.LastWriteTime)
|
||||||
|
{
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
if (result)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
if (!result)
|
||||||
|
{ }
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1216,7 +1231,55 @@ public partial class DlibDotNet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private (string, ReadOnlyCollection<string[]>) GetFilesCollectionThenCopyOrMove(long ticks, string fileSearchFilter, string directorySearchFilter, ProgressBarOptions options, string outputResolution)
|
private static void CheckForAllWindowsLinks(ReadOnlyCollection<string[]> filesCollection)
|
||||||
|
{
|
||||||
|
string fileFullPath;
|
||||||
|
WindowsShortcut windowsShortcut;
|
||||||
|
foreach (string[] files in filesCollection)
|
||||||
|
{
|
||||||
|
if (files.Length == 0)
|
||||||
|
continue;
|
||||||
|
if (files.All(l => l.EndsWith(".lnk")))
|
||||||
|
{
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
windowsShortcut = WindowsShortcut.Load(file);
|
||||||
|
if (windowsShortcut.Path is null)
|
||||||
|
{
|
||||||
|
File.Delete(file);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
fileFullPath = windowsShortcut.Path;
|
||||||
|
windowsShortcut.Dispose();
|
||||||
|
File.WriteAllText(Path.ChangeExtension(file, ".url"), fileFullPath);
|
||||||
|
File.Delete(file);
|
||||||
|
}
|
||||||
|
throw new NotSupportedException("All are Windows *.lnk files!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsFilesCollectionCountIsOne(ReadOnlyCollection<string[]> filesCollection)
|
||||||
|
{
|
||||||
|
bool result = true;
|
||||||
|
int count = 0;
|
||||||
|
foreach (string[] files in filesCollection)
|
||||||
|
{
|
||||||
|
if (files.Length == 0)
|
||||||
|
continue;
|
||||||
|
count += 1;
|
||||||
|
if (count > 1)
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (result)
|
||||||
|
CheckForAllWindowsLinks(filesCollection);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private (string, ReadOnlyCollection<string[]>, bool) GetFilesCollectionThenCopyOrMove(long ticks, string fileSearchFilter, string directorySearchFilter, ProgressBarOptions options, string outputResolution)
|
||||||
{
|
{
|
||||||
ProgressBar progressBar;
|
ProgressBar progressBar;
|
||||||
string filesCollectionRootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
string filesCollectionRootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||||
@ -1224,6 +1287,7 @@ public partial class DlibDotNet
|
|||||||
IReadOnlyDictionary<string, string[]> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, [_Configuration.PropertyConfiguration.ResultContent]);
|
IReadOnlyDictionary<string, string[]> fileGroups = Shared.Models.Stateless.Methods.IPath.GetKeyValuePairs(_Configuration.PropertyConfiguration, cResultsFullGroupDirectory, [_Configuration.PropertyConfiguration.ResultContent]);
|
||||||
ReadOnlyCollection<string[]> filesCollection = IDirectory.GetFilesCollection(filesCollectionRootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage: false);
|
ReadOnlyCollection<string[]> filesCollection = IDirectory.GetFilesCollection(filesCollectionRootDirectory, directorySearchFilter, fileSearchFilter, useCeilingAverage: false);
|
||||||
int count = filesCollection.Select(l => l.Length).Sum();
|
int count = filesCollection.Select(l => l.Length).Sum();
|
||||||
|
bool filesCollectionCountIsOne = IsFilesCollectionCountIsOne(filesCollection);
|
||||||
string message = $") Selecting for ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
string message = $") Selecting for ## pattern directory - {(int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds)} total second(s)";
|
||||||
progressBar = new(count, message, options);
|
progressBar = new(count, message, options);
|
||||||
(string[] distinctDirectories, List<(FilePath, string)> toDoCollection) = IDirectory.GetToDoCollection(_Configuration.PropertyConfiguration, filesCollection, fileGroups[_Configuration.PropertyConfiguration.ResultContent], () => progressBar.Tick());
|
(string[] distinctDirectories, List<(FilePath, string)> toDoCollection) = IDirectory.GetToDoCollection(_Configuration.PropertyConfiguration, filesCollection, fileGroups[_Configuration.PropertyConfiguration.ResultContent], () => progressBar.Tick());
|
||||||
@ -1237,7 +1301,7 @@ public partial class DlibDotNet
|
|||||||
progressBar = new(count, message, options);
|
progressBar = new(count, message, options);
|
||||||
_ = IDirectory.CopyOrMove(toDoCollection, move: false, moveBack: false, () => progressBar.Tick());
|
_ = IDirectory.CopyOrMove(toDoCollection, move: false, moveBack: false, () => progressBar.Tick());
|
||||||
progressBar.Dispose();
|
progressBar.Dispose();
|
||||||
return (filesCollectionRootDirectory, new(filesCollection));
|
return (filesCollectionRootDirectory, new(filesCollection), filesCollectionCountIsOne);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -87,6 +87,8 @@ internal abstract class Container
|
|||||||
FilePath filePath = FilePath.Get(propertyConfiguration, imageFileInfo, index: null);
|
FilePath filePath = FilePath.Get(propertyConfiguration, imageFileInfo, index: null);
|
||||||
bool? fileSizeChanged = property is not null ? property.FileSize != filePath.Length : null;
|
bool? fileSizeChanged = property is not null ? property.FileSize != filePath.Length : null;
|
||||||
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered);
|
bool isValidImageFormatExtension = propertyConfiguration.ValidImageFormatExtensions.Contains(filePath.ExtensionLowered);
|
||||||
|
if (property is not null && property.Keywords is not null && !IId.IsIgnore(filePath) && propertyConfiguration.IgnoreRulesKeyWords.Any(l => property.Keywords.Contains(l)))
|
||||||
|
throw new NotSupportedException($"Rename File! <{filePath.FileNameFirstSegment}>");
|
||||||
string relativePath = IPath.GetRelativePath(filePair.Path, rootDirectoryLength, forceExtensionToLower: true);
|
string relativePath = IPath.GetRelativePath(filePair.Path, rootDirectoryLength, forceExtensionToLower: true);
|
||||||
bool? lastWriteTimeChanged = property is not null ? propertyConfiguration.PropertiesChangedForProperty || property.LastWriteTime.Ticks != filePath.LastWriteTicks : null;
|
bool? lastWriteTimeChanged = property is not null ? propertyConfiguration.PropertiesChangedForProperty || property.LastWriteTime.Ticks != filePath.LastWriteTicks : null;
|
||||||
if (filePair.Match is not null)
|
if (filePair.Match is not null)
|
||||||
|
@ -18,6 +18,24 @@ public interface IId
|
|||||||
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int index, int id) =>
|
static string GetPaddedId(Properties.IPropertyConfiguration propertyConfiguration, int index, int id) =>
|
||||||
Id.GetPaddedId(propertyConfiguration, index, id);
|
Id.GetPaddedId(propertyConfiguration, index, id);
|
||||||
|
|
||||||
|
bool TestStatic_IsIgnore(FilePath filePath) =>
|
||||||
|
IsIgnore(filePath);
|
||||||
|
static bool IsIgnore(FilePath filePath) =>
|
||||||
|
filePath.FileNameFirstSegment[^1] is '2' or '8';
|
||||||
|
|
||||||
|
string TestStatic_GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
|
||||||
|
GetIgnoreFullPath(filePath, fileHolder);
|
||||||
|
static string GetIgnoreFullPath(FilePath filePath, Models.FileHolder fileHolder) =>
|
||||||
|
fileHolder.DirectoryName is null ?
|
||||||
|
throw new NotSupportedException() :
|
||||||
|
filePath.Id > -1 ?
|
||||||
|
fileHolder.NameWithoutExtension[^1] == '9' ?
|
||||||
|
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}8{fileHolder.ExtensionLowered}") :
|
||||||
|
throw new NotSupportedException("High") :
|
||||||
|
fileHolder.NameWithoutExtension[^1] == '1' ?
|
||||||
|
Path.Combine(fileHolder.DirectoryName, $"{fileHolder.NameWithoutExtension[..^1]}2{fileHolder.ExtensionLowered}") :
|
||||||
|
throw new NotSupportedException("Low");
|
||||||
|
|
||||||
bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
|
bool TestStatic_NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
|
||||||
NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
NameWithoutExtensionIsIntelligentIdFormat(propertyConfiguration, fileNameFirstSegment);
|
||||||
static bool NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
|
static bool NameWithoutExtensionIsIntelligentIdFormat(Properties.IPropertyConfiguration propertyConfiguration, string fileNameFirstSegment) =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user