This PowerShell script is designed to help you efficiently rename files in a specified directory. It offers various functionalities, including removing extra underscores, unwanted special characters, spaces, and adding prefixes. It also supports word replacement within filenames. The script logs activities and errors, providing feedback on operations and user interactions.
- Remove Extra Underscores: Removes all but the first underscore from filenames. ✂️
- Remove Spaces: Eliminates spaces from filenames. 🚫
- Remove Unwanted Characters: Removes characters not specified by the user while preserving certain characters. 🧹
- Add Prefix: Adds a user-defined prefix to filenames. 🏷️
- Remove First Underscore: Removes the first underscore from filenames. 🆗
- Replace Word in Filenames: Replaces specified words in filenames with new ones. 🔄
- Activity Logging: Logs user activities and errors to a log file. 📜
- User Interaction: Prompts users for actions and preferences, with options for retrying or exiting. 💬
-
Clone or Download: Obtain the script file from the repository or copy the code into a
.ps1
file. 📥 -
Execution Policy: Ensure that your PowerShell execution policy allows running scripts. You can set the policy with:
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
-
Run the Script: Open PowerShell and navigate to the directory containing the script. Execute it with:
.\YourScriptName.ps1
-
Launch the Script: Run the script from PowerShell. 🚀
-
Select an Option: Choose from the available options in the menu:
1. Remove underscores (except the first one)
🛠️2. Remove spaces
🗑️3. Remove unwanted special characters
🚫🔣4. Add prefix to filenames
🏷️5. Remove the first underscore
🆗6. Replace a word in filenames
🔄7. Exit
❌
-
Follow Prompts: Enter required details as prompted by the script (e.g., prefix, characters to preserve, words to replace). ✍️
-
Review Logs: Check the
file_renamer.log
in your user profile directory for detailed logs of the operations performed. 📜 -
User Activity: View or update the
last_user_activity.txt
file in your user profile directory to see the latest user activity. 👤
To remove extra underscores from filenames in a directory:
- Choose option
1
from the menu. 🔧 - The script will process files in the current directory, modifying filenames as specified. 🗂️
- Invalid Directory: Ensure you enter a valid directory path. 🛣️
- File Exists: If a file with the new name already exists, the script will skip renaming and log the error.
⚠️
This script is provided as-is. Use it at your own risk, and ensure you have backups of your files before running the script. 🛡️
For issues or inquiries, please contact the developer or refer to the script's documentation. 📬