Exemple #1
0
        public void TestPatternRename()
        {
            string org = "E:\\coba1\\coba.html";

            var fullPathObj = new PowerPath(org);
            var values      = ValueObject.CreateMock();
            var result      = fullPathObj.RenameFileByPattern("{Name}{Value}", values);

            Assert.AreEqual("Fahmit.html", result.GetFileName());
        }
Exemple #2
0
        private void RenameFile(PowerPath fileInfo, MovieEntryFacade entry)
        {
            var originalFilePath = fileInfo.GetFullPath();
            var renamedFile      = fileInfo.RenameFileByPattern(FileRenamePattern, entry);

            if (SwapThe)
            {
                renamedFile.SwapFileName(Commons.TheName);
            }
            var name = renamedFile.GetFileName();

            var destFilePath = Path.Combine(fileInfo.GetDirectoryPath(), name);

            if (originalFilePath == destFilePath)
            {
                return;
            }
            File.Move(originalFilePath, destFilePath);
            entry.FullPath = destFilePath;
        }
        private void HelperRenameFile(string path, MovieEntry entry)
        {
            // store original path
            var fileInfo         = new PowerPath(path);
            var originalFilePath = fileInfo.GetFullPath();

            // rename path
            var renamedFile = fileInfo.RenameFileByPattern(_settings.FileRenamePattern, entry);

            if (_settings.SwapThe)
            {
                renamedFile.SwapFileName(Commons.TheName);
            }

            // rename
            if (originalFilePath == renamedFile)
            {
                return;
            }
            File.Move(originalFilePath, renamedFile);
        }