Skip to content

VydrOz/renaming-files-correctly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents

📖 Context

v1

Following a personal request from a family member. I wrote a script to rename files (type defined in, e.g. ".txt") by removing special characters from a predefined list and replacing spaces with an underscore.

v2

The original request has evolved, I now need to export files in a csv table to rename them manually.

💡 Informations

The script takes only files from where is it. You must place it on the same path as the files to be renamed.

🖥️ Preview

Considering this tree :

📂 Desktop/
├─ 📂 Memes/
│  └─ 📹 RickRoll.wav
├─ 📂 TestFolder/
│  ├─ 📂 1/
│  │  └─ 📄 text file.txt
│  ├─ 📜 .ExportFilesToCsv.ps1
│  ├─ 📜 .RenameCorrectlyFiles.ps1
│  ├─ 📜 .RenameCorrectlyFilesToCsv.ps1
│  ├─ 📄 another #   test  file----  .txt
│  ├─ 📄 a test     file      .txt
│  ├─ 📄 one       more $ .txt
│  ├─ 📄 Ze last [test file].txt
│  └─ 🖼️ 2022-02-14-00042354.png
├─ 📂 UwU/
│  └─ 📄 Cat tier list.txt  

v1 - Result

  1. .RenamingFilesCorrectly.ps1

    image

v2 - Steps

  1. .ExportFilesToCsv.ps1

    image

    ... wich creates the file Files_To_Rename.csv

    Notepad Excel
    "Actual file name";"New file name"
    "a test     file      .txt";""
    "another #   test  file----  .txt";""
    "one       more $ .txt";""
    "Ze last [test file].txt";""
    
    Actual file name New file name
    a test file .txt
    another # test file---- .txt
    one more $ .txt
    Ze last [test file].txt
  2. Modify csv with custom names

    Notepad Excel
    "Actual file name";"New file name"
    "a test     file      .txt";"test_file.txt"
    "another #   test  file----  .txt";"another_file.txt"
    "one       more $ .txt";"oneMore.txt"
    "Ze last [test file].txt";"TheLastTestFile.txt"
    
    Actual file name New file name
    a test file .txt test_file.txt
    another # test file---- .txt another_file.txt
    one more $ .txt oneMore.txt
    Ze last [test file].txt TheLastTestFile.txt
  3. .RenamingFilesFromCsv.ps1

    image