This project recursively copies files from specific folders in "LED Main - 2019" to designated department folders in a new SharePoint site. The tool handles large file transfers by moving files individually while preserving the complete folder structure.
- Issue: Cannot move large folders from old SharePoint to new SharePoint via web interface due to file size limitations
- Solution: Recursively copy files one by one using Microsoft Graph API, bypassing web interface limitations
- Benefit: Maintains folder structure while handling large files and providing detailed progress tracking
- ✅ Recursive file copying - Preserves complete folder structure
- ✅ Large file handling - Bypasses web interface size limitations
- ✅ Progress tracking - Resume interrupted operations
- ✅ Detailed logging - Complete operation audit trail
- ✅ Failed file reporting - Log files that cannot be moved for manual review
- ✅ Excel mapping - Configure source-to-destination folder mappings
LED File Copier/
├── LEDFileCopier.py # Main application
├── test_first_folder.py # Test script for single folder
├── requirements.txt # Python dependencies
├── Onedrive folder mapping.xlsx # Source to destination mappings
├── .env # Environment variables (you create this)
└── README.md # This file
Generated during operation:
├── led_file_copier.log # Detailed operation log
├── led_copier_progress.json # Progress tracking (resumable)
└── failed_files_microsoft_ticket.json # Failed files report
pip install -r requirements.txtYou need the same Azure AD app registration used in the original SharePoint sorter:
- Tenant ID
- Client ID
- Client Secret
Create a .env file in the project directory:
TENANT_ID=your-tenant-id-here
CLIENT_ID=your-client-id-here
CLIENT_SECRET=your-client-secret-here
Ensure the Azure AD app has:
Sites.ReadWrite.All- Read/write access to SharePoint sitesFiles.ReadWrite.All- Read/write access to files
Before running the full operation, test with a single folder:
python3 test_first_folder.pyThis will copy "2020 LC Spec Sheets" → "LED/Engineering" as a test.
python3 LEDFileCopier.pyThe application will:
- Load folder mappings from Excel file
- Authenticate with Microsoft Graph API
- Initialize source and destination SharePoint drives
- Ask for confirmation before starting
- Copy all 108 mapped folders recursively
- Generate detailed reports
The Onedrive folder mapping.xlsx file contains 108 mappings with headers:
Current Folder (LED Main - 2019) | Destination
Example mappings (actual data rows):
2020 LC Spec Sheets → LED/Engineering
Accounting → LED/Finance
Jobs → LED/Jobs
B & H Lighting → B&H
NRG Hunters → NRG
The application saves progress to led_copier_progress.json. If interrupted:
- Restart the application
- It will skip already processed files
- Continue from where it left off
During operation, you'll see:
Processing folder mapping: Accounting -> LED/Finance
Found 245 files in Accounting
Successfully copied: LED Main - 2019/Accounting/file1.xlsx -> LED/Finance/file1.xlsx
...
Completed folder copy: Accounting - Success: 243, Errors: 2
Files that cannot be copied are automatically logged to failed_files_microsoft_ticket.json with:
- Complete file paths (source and destination)
- File sizes and metadata
- Error codes and responses
- SharePoint site information
- File categorization (Large file vs Standard file)
When files fail to copy:
- The application generates
failed_files_microsoft_ticket.json - Review the file to identify problematic files
- Use the information for manual intervention or Microsoft Support if needed
- Large files (>100MB) are flagged for special attention
{
"summary": {
"total_failed_files": 5,
"error_categories": {
"Upload failed": 3,
"Download failed": 2
},
"largest_files": [...],
"instructions": "Use this report to identify files that failed to copy..."
},
"failed_files": [
{
"source_file_path": "LED Main - 2019/Accounting/large_file.zip",
"destination_path": "LED/Finance",
"file_size_mb": 150.5,
"error_type": "Upload failed",
"http_status_code": 413,
"file_priority": "Large file"
}
]
}led_file_copier.log- Detailed operation log with timestampsled_copier_progress.json- Progress tracking for resume capabilityfailed_files_microsoft_ticket.json- Failed files report for manual review
COPY OPERATION COMPLETED
==================================================
Total files processed: 15,847
Successful copies: 15,832
Failed copies: 15
Success rate: 99.9%
⚠️ MICROSOFT TICKET REQUIRED:
Files requiring Microsoft assistance: 15
Largest failed file: 250.3 MB
Failed files report: failed_files_microsoft_ticket.json
Review failed_files_microsoft_ticket.json for files requiring manual attention.
Update these constants in LEDFileCopier.py if needed:
SOURCE_SITE = "ledconnection2015.sharepoint.com"
SOURCE_SITE_PATH = "/sites/Documents/LED Main - 2019"
DEST_SITE = "ledconnection2015.sharepoint.com"
DEST_SITE_PATH = "/sites/DhilenTestProjectPage"The application includes built-in delays:
- 0.5 seconds between individual file copies
- Progress saved every 10 files
- Automatic retry logic for temporary failures
❌ Failed to authenticate
Solution: Verify .env file contains correct Azure AD credentials
❌ Failed to initialize SharePoint drives
Solution: Ensure Azure AD app has proper SharePoint permissions
⚠️ FAILED FILE LOGGED: large_file.zip (250.1MB) - Upload failed
Solution: This is expected for very large files - review the failed files report for manual handling
The application automatically resumes by:
- Loading
led_copier_progress.json - Skipping already processed files
- Continuing from last position
- Small files (<1MB): ~2-3 files per second
- Medium files (1-10MB): ~1 file per second
- Large files (>10MB): Several seconds per file
- Very large files (>100MB): May fail and require manual handling
- ~16,000 files estimated: 4-8 hours depending on file sizes
- Resume capability: Can run over multiple days if needed
- Progress tracking: Never lose work due to interruptions
- First: Run
python3 test_first_folder.pyto test with one folder - Verify: Check that files copied correctly to LED/Engineering
- Then: Run
python3 LEDFileCopier.pyfor full operation - Monitor: Watch logs and progress files during operation
- Review
led_file_copier.logfor detailed operation information - Check
failed_files_microsoft_ticket.jsonfor files requiring manual attention - Use
led_copier_progress.jsonfor resume capability status