A robust Python utility for safely relocating Windows user folders to different locations while maintaining system integrity.
-
π‘οΈ Safety First
- ποΈ Registry automatic backup
- π File integrity verification
- π Progress tracking
- π Detailed logging
- πΎ Space verification
- π Admin privileges check
-
π Supported Folders
- π Documents
- π₯ Downloads
- πΌοΈ Pictures
- π΅ Music
- π₯ Videos
- π₯οΈ Desktop
-
Overwrite Options
- π Overwrite Existing Files
- π Overwrite Existing Folders
- ππ Overwrite All Existing Files and Folders
- π₯οΈ Windows 10/11
- π Python 3.8+
- π Administrator privileges
- π¦ Required Python packages (see requirements.txt)
- π₯οΈ wxPython for GUI support
- Clone the repository:
git clone https://github.com/shaerif/windows-user-folders-relocation-tool.git
- Install dependencies:
pip install -r requirements.txt
- π₯οΈ Supported OS: Windows 10/11
- β Unsupported OS: Other operating systems are not supported.
Ensure all dependencies are installed by running:
pip install -r requirements.txt
The tool automatically detects user directories and available drives, making it compatible with any Windows setup.
To compile the script to an executable format for Windows, you can use PyInstaller
.
- Install PyInstaller:
pip install pyinstaller
- Compile the script:
pyinstaller --onefile folder-relocator.py
This will create a single executable file in the dist
directory.
- Command Line Usage:
python folder-relocator.py --target <TARGET_PATH> --overwrite-all
- Replace
<TARGET_PATH>
with your desired target path. - Use other arguments as needed based on
--help
.
- CLI Overwrite Options:
--overwrite-files
: Overwrite existing files in the target location.--overwrite-folders
: Overwrite existing folders in the target location.--overwrite-all
: Overwrite all existing files and folders in the target location.
- GUI Usage:
- If no
--target
argument is provided, the GUI will launch by default, allowing you to select the target drive and folders to relocate. - Overwrite Options in GUI:
- Overwrite Existing Files: Check to allow overwriting of existing files.
- Overwrite Existing Folders: Check to allow overwriting of existing folders.
- Overwrite All: Check to allow overwriting of all existing files and folders without individual prompts.
-
Pre-move Checks:
- π Administrative privileges verification
- πΎ Disk space validation (minimum 5GB required)
- π Path accessibility check
- ποΈ Registry backup creation
-
During Move:
- π Progress tracking
- π File integrity verification
- ποΈ Original location preservation
- π Junction point creation
-
Post-move Verification:
- π File count matching
- π Checksum verification
- π Registry update confirmation
- Default:
C:\Users\[YourUsername]\Documents
- Purpose: For personal documents (e.g., Word, Excel, PDFs).
- Relocation: Can be relocated via the folder's Properties > Location tab.
- Default:
C:\Users\[YourUsername]\Downloads
- Purpose: Default location for internet downloads.
- Relocation: Can be relocated through Properties > Location.
- Default:
C:\Users\[YourUsername]\Pictures
- Purpose: Stores images, photos, and screenshots.
- Relocation: Can be moved using the Location tab.
- Default:
C:\Users\[YourUsername]\Music
- Purpose: For music and audio files.
- Relocation: Relocatable via Properties > Location.
- Default:
C:\Users\[YourUsername]\Videos
- Purpose: For video files and recordings.
- Relocation: Can be moved through the Location tab.
- Default:
C:\Users\[YourUsername]\Desktop
- Purpose: Stores files and shortcuts visible on the desktop.
- Relocation: Can be relocated.
- Default:
C:\Users\[YourUsername]\AppData
- Purpose: Stores application-specific data.
- Subfolders: Local, Roaming, LocalLow
- Caution: Moving AppData requires symbolic links to avoid breaking paths for applications.
- Default:
- System Temp:
C:\Windows\Temp
- User Temp:
C:\Users\[YourUsername]\AppData\Local\Temp
- System Temp:
- Purpose: Stores temporary files used by the system and applications.
- Relocation: Can be redirected via Environment Variables settings.
- Default:
C:\Users\[YourUsername]\OneDrive
- Purpose: Sync location for OneDrive files.
- Relocation: Can be moved through OneDrive settings.
- Default:
C:\Users\Public
- Purpose: For shared files among all users.
- Relocation: Can be moved manually or via symbolic links.
- Includes: Documents, Pictures, Music, Videos libraries.
- Relocation: Can be redirected via Settings > System > Storage > Change where new content is saved.
When relocating user folders, the files will be organized under a folder named after the username on the target drive. For example, if the target drive is D:
and the username is [YourUsername]
, the files will be moved to:
D:\
βββ [YourUsername]\
βββ Documents\
βββ Downloads\
βββ Pictures\
βββ Music\
βββ Videos\
βββ Desktop\
To avoid issues while moving files, it is recommended to run the script as an administrator. You can do this by right-clicking on the script or executable and selecting "Run as administrator".
To ensure the CLI operates with the necessary permissions, follow these steps:
-
Open Command Prompt as Administrator:
- Press
Win + X
and select Command Prompt (Admin) or Windows PowerShell (Admin). - Alternatively, search for
cmd
in the Start menu, right-click Command Prompt, and choose Run as administrator.
- Press
-
Navigate to the Project Directory:
cd path/to/Windows_User_Folders_Relocation_App
- Execute the CLI Script:
python folder-relocator-cli.py --target <TARGET_PATH> --overwrite-all
- Replace
<TARGET_PATH>
with your desired target path. - Use other arguments as needed based on
--help
.
If you encounter errors similar to those in your logs, consider the following steps:
-
Permission Denied ([WinError 5]):
- Ensure Admin Privileges: Double-check that the CLI is running with administrative rights.
- Close Open Applications: Make sure no applications are using the folders you intend to relocate.
- Antivirus Interference: Temporarily disable antivirus software that might restrict folder modifications.
-
File Not Found ([WinError 2] & [WinError 3]):
- Verify Paths: Ensure that the source and target paths exist and are correctly specified.
- Check Folder Names: Confirm that folder names match exactly, including case sensitivity.
-
Logging and Error Details:
- Review Log Files: Check the log files located in
WindowsUserFoldersRelocation/logs/
for detailed error messages. - Example Log Analysis:
2025-01-03 07:29:34,195 - ERROR - Moving folder contents failed: [Errno 13] Permission denied: 'C:\\Users\\[YourUsername]\\Documents'
- Interpretation: The script lacked sufficient permissions to move the
Documents
folder. - Action: Ensure the CLI is run as an administrator and that no processes are locking the folder.
- Interpretation: The script lacked sufficient permissions to move the
- Review Log Files: Check the log files located in
Both the CLI and GUI should exhibit similar behaviors and handle errors uniformly. To achieve this:
-
Consistent Logging:
- Ensure both interfaces log errors and actions to the same log files.
- Review log messages to confirm they follow a consistent format.
-
Error Handling:
- Implement uniform error checks in both CLI and GUI scripts.
- Provide clear and actionable error messages to the user.
-
Permissions Verification:
- Both interfaces should verify and request administrative privileges before performing operations.
- Consistent prompts and escalation methods enhance reliability.
-
Testing:
- Test both CLI and GUI with identical parameters to ensure they produce the same outcomes.
- Validate that errors encountered in CLI are reproducible in the GUI and vice versa.
By following these guidelines and implementing the necessary code modifications, you can ensure that both the CLI and GUI operate seamlessly and handle permissions and errors effectively.
-
Access Denied:
- Run as administrator
- Close all applications using target folders
-
Insufficient Space:
- Free up space on target drive
- Choose a different location
-
File in Use:
- Close all applications
- Restart Windows Explorer
-
Before Moving:
- Backup important data
- Close all applications
- Run disk check (chkdsk)
-
Location Selection:
- Choose a dedicated partition
- Ensure adequate free space
- Use local drives for better performance
For issues and support:
- Check the logs in the application directory
- Open an issue on GitHub
- Include log files when reporting problems
-
Permission Issues:
- Ensure you are running the script with administrative privileges.
- Ensure you are running the script with administrative privileges.
-
Insufficient Disk Space:
- Verify that the target drive has at least 5GB of free space.
-
Unsupported Operating System:
- This tool is only compatible with Windows 10 and 11.
-
Unexpected Errors:
- Check the log files located in
WindowsUserFoldersRelocation/logs
for detailed error messages.
- Check the log files located in
Contributions are welcome! Please fork the repository and submit a pull request for any enhancements or bug fixes.
This project utilizes GitHub Actions to ensure code quality and functionality. Every push and pull request triggers automated unit and integration tests, providing immediate feedback on the health of the codebase.
- Checkout Repository: The workflow checks out the latest code from the repository.
- Set Up Python: It sets up the specified Python environment.
- Install Dependencies: Installs all required Python packages.
- Run Tests: Executes both unit and integration tests to validate changes.
You can view the status of the CI pipeline in the repository's Actions tab. Successful tests ensure that your contributions meet the project's standards and do not introduce regressions.
# GitHub Actions workflows are defined in the .github/workflows/ci.yml file.
# The CI pipeline runs automatically on every push and pull request to the main branch.
Non-Commercial Educational and Non-Profit License - See LICENSE file for details
Log files are automatically created in the WindowsUserFoldersRelocation/logs
directory within your home folder. These logs track all operations performed by the tool, including any errors encountered.
After running the application, you can find the log files at:
<path_to_home_directory>/WindowsUserFoldersRelocation/logs/
These logs provide detailed information about the operations performed by the tool, which can be useful for troubleshooting and verifying actions.
Metric | Value |
---|---|
Time Invested | 13 hours and 40 minutes |
Last Updated | 2025-01-04 10:50:23 EST |
Release Status | Beta |
Active Contributors | 1 |
Note: Time tracking started from project inception. Updates are automated via GitHub Actions.