audio-files-organizer-iphone


Nameaudio-files-organizer-iphone JSON
Version 0.0.3 PyPI version JSON
download
home_pagehttps://github.com/David-Sandeep/audio-files-organizer-iphone
SummaryA tool for organizing audio files for iPhone compatibility
upload_time2024-11-21 20:21:09
maintainerNone
docs_urlNone
authorDavid Sandeep
requires_python>=3.7
licenseMIT License Copyright (c) 2024 David Sandeep Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords audio organizer metadata iphone
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # audio_files_organizer_for_iphone
Organize audio files and update their metadata to maintain the original folder structure. Perfect for syncing music to iTunes and Apple Music while preserving album organization. Automates tedious metadata edits, saving time and effort for large audio collections.



# Audio File Metadata Organizer 

### Introduction

#### What is this Script?
This Python script automates the organization and metadata updating of audio files. It helps users who have large audio collections stored in various folder structures maintain those structures when syncing to Apple Music or other music players. The script ensures that albums and songs appear organized, as per the folder hierarchy, on devices like iPhones.

#### Why is it Needed?
Manually editing metadata (like album names, contributing artists, etc.) for large music collections is tedious and error-prone. This script:
- Updates the metadata to match the parent folder's name for each audio file.
- Moves processed files to a single consolidated folder.
- Ensures compatibility with Apple Music/iTunes, maintaining the folder structure on synced devices.
- Saves time by automating repetitive tasks.

#### When to Use It?
Use this script when:
1. You have a large number of audio files organized in a folder structure on your hard disk.
2. You want to maintain the folder hierarchy for albums and tracks on devices like iPhones or iPads.
3. You need metadata corrected without manually editing each file.

#### Who is it For?
- Music enthusiasts with large audio libraries.
- iPhone users syncing music via iTunes/Apple Music.
- Anyone wanting to save time on organizing music collections.

---

### How the Script Works

#### Workflow

1. **Select Base Folder**:
    - The script prompts you to choose a folder containing your audio files. This is the source directory for processing.
    
2. **Scan for Audio Files**:
    - The script recursively scans the base folder for supported audio file formats (.mp3, .wav, .flac, .m4a, etc.).
    - Files shorter than 1 minute in length are skipped.
    
3. **Update Metadata**:
    - For each audio file, the script updates the Album and Artist metadata to match the name of the parent folder.
    - It uses the `mutagen` library to make these changes.
    
4. **Retry Failed Files with Re-Encoding**:
    - If updating metadata fails, the script tries to re-encode the audio file using FFmpeg, ensuring compatibility.
    
5. **Move Processed Files**:
    - Successfully processed files are moved to a folder named `audio songs`, preserving the folder structure, if user prompt's yes then all files will move to target location.
    
6. **Generate Logs**:
    - The script generates logs for:
        - Successfully processed files.
        - Files that failed metadata updates.
        - Files that failed even after re-encoding.
    
7. **Sync to iTunes**:
    - Once all files are moved to the `audio songs` folder, simply drag this folder into iTunes to sync with your iPhone.

---

### Key Features

#### Supported Audio Formats
The script supports a variety of audio formats, including:
- MP3
- WAV
- FLAC
- M4A
- AAC
- OGG
- WMA

#### Folder Structure Preservation
The script ensures that the folder structure in the `audio songs` directory matches the original hierarchy. This guarantees that albums appear grouped correctly in the Apple Music app.

#### Metadata Updates
- **Album Name**: Set to the parent folder name.
- **Contributing Artist**: Also set to the parent folder name, ensuring uniformity across tracks in an album.

#### Error Handling and Re-Encoding
- Files that fail during metadata updates are re-encoded using FFmpeg to resolve compatibility issues.
- A separate log is generated for files that still fail after re-encoding.

#### Size Calculation
The total size of successfully processed files is calculated and displayed, helping ensure there is enough space in the target directory.

---

### Script Components

#### Functions

1. **normalize_path(path)**:
    - Normalizes file paths for cross-platform compatibility.

2. **get_audio_files(base_directory)**:
    - Recursively scans the base directory for audio files in supported formats.

3. **calculate_total_size(file_paths)**:
    - Computes the total size of all successfully processed files.

4. **update_album_metadata(file_path)**:
    - Updates the metadata (Album, Artist) of an audio file.

5. **reencode_audio(file_path, temp_path)**:
    - Re-encodes an audio file using FFmpeg to resolve compatibility issues.

6. **move_audio_files(audio_files, target_folder)**:
    - Moves processed files to the target directory while preserving folder hierarchy.

7. **save_log(file_path, log_data, file_count)**:
    - Saves logs of processed files with timestamps.

8. **process_files(base_directory, target_directory)**:
    - Orchestrates the workflow of scanning, processing, and moving files.

9. **processit()**:
    - Handles user interaction and starts the processing workflow.

---

### Example Usage

#### Scenario
You have a folder structure on your hard drive like this:



Music/ ├── Album1/ │ ├── song1.mp3 │ ├── song2.mp3 ├── Album2/ │ ├── track1.m4a │ ├── track2.wav



You want to:
- Update all metadata so that **Album1's** tracks have the same album name and artist: **Album1**.
- Consolidate everything into a single directory named `audio songs`, while retaining the folder structure.


## Steps to Use the Package

### 1. Install the Package
Install the following packages, run the following commands:

```bash
pip install mutagen
```

```bash
pip install audio-files-organizer-iphone
```

### 2. Run the Script by Importing the Package
After installation, run the script by importing the package and calling the `processit()` function:

```python
from  Audio_files_organizer_for_iphone import Audio_organizer
Audio_organizer.processit()
```

### 3. Select the Base Directory
When prompted, select the `Music/` directory as the base directory.

### 4. Choose the Target Directory
Next, choose a target directory where the `audio songs` folder will be created.

### 5. Once Processing is Complete
After processing is finished:
- Drag the `audio songs` folder into **iTunes**.
- Sync your iPhone to reflect the updated folder structure.

---

### Limitations
- **Album Art**: The script does not handle album artwork. Apple Music may download artwork automatically.
- **File Length Check**: Files shorter than 1 minute are ignored.
- **FFmpeg Dependency**: Ensure FFmpeg is installed and added to your system’s PATH.

---

### System Requirements

- **Python 3.7+**
- Libraries: `os`, `shutil`, `mutagen`, `subprocess`, `datetime`, `tkinter`
- **FFmpeg** for audio re-encoding (optional for re-encoding failed files)

---

### Developer Statement

I am David Sandeep, and I created this script to address my own challenges with organizing and syncing a vast library of audio files. Editing metadata manually was too tedious, so this script became my solution. It processed **34.57 GB** of files, organized them into a folder called `audio songs`, and saved me countless hours. By simply dragging this folder into iTunes, I was able to sync the files to my iPhone 14 Pro Max while maintaining the original folder structure.

If you have a similar need, this script can save you time and ensure your music library stays organized when synced to Apple devices.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/David-Sandeep/audio-files-organizer-iphone",
    "name": "audio-files-organizer-iphone",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "audio, organizer, metadata, iphone",
    "author": "David Sandeep",
    "author_email": "David Sandeep <davidsandeep1996@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/99/78/2c9028bcc553b4271d81a0d1f9531c19c4da532a5a67997fdfb052ab532e/audio_files_organizer_iphone-0.0.3.tar.gz",
    "platform": null,
    "description": "# audio_files_organizer_for_iphone\nOrganize audio files and update their metadata to maintain the original folder structure. Perfect for syncing music to iTunes and Apple Music while preserving album organization. Automates tedious metadata edits, saving time and effort for large audio collections.\n\n\n\n# Audio File Metadata Organizer \n\n### Introduction\n\n#### What is this Script?\nThis Python script automates the organization and metadata updating of audio files. It helps users who have large audio collections stored in various folder structures maintain those structures when syncing to Apple Music or other music players. The script ensures that albums and songs appear organized, as per the folder hierarchy, on devices like iPhones.\n\n#### Why is it Needed?\nManually editing metadata (like album names, contributing artists, etc.) for large music collections is tedious and error-prone. This script:\n- Updates the metadata to match the parent folder's name for each audio file.\n- Moves processed files to a single consolidated folder.\n- Ensures compatibility with Apple Music/iTunes, maintaining the folder structure on synced devices.\n- Saves time by automating repetitive tasks.\n\n#### When to Use It?\nUse this script when:\n1. You have a large number of audio files organized in a folder structure on your hard disk.\n2. You want to maintain the folder hierarchy for albums and tracks on devices like iPhones or iPads.\n3. You need metadata corrected without manually editing each file.\n\n#### Who is it For?\n- Music enthusiasts with large audio libraries.\n- iPhone users syncing music via iTunes/Apple Music.\n- Anyone wanting to save time on organizing music collections.\n\n---\n\n### How the Script Works\n\n#### Workflow\n\n1. **Select Base Folder**:\n    - The script prompts you to choose a folder containing your audio files. This is the source directory for processing.\n    \n2. **Scan for Audio Files**:\n    - The script recursively scans the base folder for supported audio file formats (.mp3, .wav, .flac, .m4a, etc.).\n    - Files shorter than 1 minute in length are skipped.\n    \n3. **Update Metadata**:\n    - For each audio file, the script updates the Album and Artist metadata to match the name of the parent folder.\n    - It uses the `mutagen` library to make these changes.\n    \n4. **Retry Failed Files with Re-Encoding**:\n    - If updating metadata fails, the script tries to re-encode the audio file using FFmpeg, ensuring compatibility.\n    \n5. **Move Processed Files**:\n    - Successfully processed files are moved to a folder named `audio songs`, preserving the folder structure, if user prompt's yes then all files will move to target location.\n    \n6. **Generate Logs**:\n    - The script generates logs for:\n        - Successfully processed files.\n        - Files that failed metadata updates.\n        - Files that failed even after re-encoding.\n    \n7. **Sync to iTunes**:\n    - Once all files are moved to the `audio songs` folder, simply drag this folder into iTunes to sync with your iPhone.\n\n---\n\n### Key Features\n\n#### Supported Audio Formats\nThe script supports a variety of audio formats, including:\n- MP3\n- WAV\n- FLAC\n- M4A\n- AAC\n- OGG\n- WMA\n\n#### Folder Structure Preservation\nThe script ensures that the folder structure in the `audio songs` directory matches the original hierarchy. This guarantees that albums appear grouped correctly in the Apple Music app.\n\n#### Metadata Updates\n- **Album Name**: Set to the parent folder name.\n- **Contributing Artist**: Also set to the parent folder name, ensuring uniformity across tracks in an album.\n\n#### Error Handling and Re-Encoding\n- Files that fail during metadata updates are re-encoded using FFmpeg to resolve compatibility issues.\n- A separate log is generated for files that still fail after re-encoding.\n\n#### Size Calculation\nThe total size of successfully processed files is calculated and displayed, helping ensure there is enough space in the target directory.\n\n---\n\n### Script Components\n\n#### Functions\n\n1. **normalize_path(path)**:\n    - Normalizes file paths for cross-platform compatibility.\n\n2. **get_audio_files(base_directory)**:\n    - Recursively scans the base directory for audio files in supported formats.\n\n3. **calculate_total_size(file_paths)**:\n    - Computes the total size of all successfully processed files.\n\n4. **update_album_metadata(file_path)**:\n    - Updates the metadata (Album, Artist) of an audio file.\n\n5. **reencode_audio(file_path, temp_path)**:\n    - Re-encodes an audio file using FFmpeg to resolve compatibility issues.\n\n6. **move_audio_files(audio_files, target_folder)**:\n    - Moves processed files to the target directory while preserving folder hierarchy.\n\n7. **save_log(file_path, log_data, file_count)**:\n    - Saves logs of processed files with timestamps.\n\n8. **process_files(base_directory, target_directory)**:\n    - Orchestrates the workflow of scanning, processing, and moving files.\n\n9. **processit()**:\n    - Handles user interaction and starts the processing workflow.\n\n---\n\n### Example Usage\n\n#### Scenario\nYou have a folder structure on your hard drive like this:\n\n\n\nMusic/ \u251c\u2500\u2500 Album1/ \u2502 \u251c\u2500\u2500 song1.mp3 \u2502 \u251c\u2500\u2500 song2.mp3 \u251c\u2500\u2500 Album2/ \u2502 \u251c\u2500\u2500 track1.m4a \u2502 \u251c\u2500\u2500 track2.wav\n\n\n\nYou want to:\n- Update all metadata so that **Album1's** tracks have the same album name and artist: **Album1**.\n- Consolidate everything into a single directory named `audio songs`, while retaining the folder structure.\n\n\n## Steps to Use the Package\n\n### 1. Install the Package\nInstall the following packages, run the following commands:\n\n```bash\npip install mutagen\n```\n\n```bash\npip install audio-files-organizer-iphone\n```\n\n### 2. Run the Script by Importing the Package\nAfter installation, run the script by importing the package and calling the `processit()` function:\n\n```python\nfrom  Audio_files_organizer_for_iphone import Audio_organizer\nAudio_organizer.processit()\n```\n\n### 3. Select the Base Directory\nWhen prompted, select the `Music/` directory as the base directory.\n\n### 4. Choose the Target Directory\nNext, choose a target directory where the `audio songs` folder will be created.\n\n### 5. Once Processing is Complete\nAfter processing is finished:\n- Drag the `audio songs` folder into **iTunes**.\n- Sync your iPhone to reflect the updated folder structure.\n\n---\n\n### Limitations\n- **Album Art**: The script does not handle album artwork. Apple Music may download artwork automatically.\n- **File Length Check**: Files shorter than 1 minute are ignored.\n- **FFmpeg Dependency**: Ensure FFmpeg is installed and added to your system\u2019s PATH.\n\n---\n\n### System Requirements\n\n- **Python 3.7+**\n- Libraries: `os`, `shutil`, `mutagen`, `subprocess`, `datetime`, `tkinter`\n- **FFmpeg** for audio re-encoding (optional for re-encoding failed files)\n\n---\n\n### Developer Statement\n\nI am David Sandeep, and I created this script to address my own challenges with organizing and syncing a vast library of audio files. Editing metadata manually was too tedious, so this script became my solution. It processed **34.57 GB** of files, organized them into a folder called `audio songs`, and saved me countless hours. By simply dragging this folder into iTunes, I was able to sync the files to my iPhone 14 Pro Max while maintaining the original folder structure.\n\nIf you have a similar need, this script can save you time and ensure your music library stays organized when synced to Apple devices.\n\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 David Sandeep  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A tool for organizing audio files for iPhone compatibility",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/David-Sandeep/audio-files-organizer-iphone"
    },
    "split_keywords": [
        "audio",
        " organizer",
        " metadata",
        " iphone"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2bf35428755a4b16de03cbc7645165e2a5a76ee75551d36da6b05cd318977996",
                "md5": "6161ab044d5f1d0f94a40e39a8b7d84f",
                "sha256": "000ab8c4b92de36144b38b68929a38bbe369a40fbb5fdb63f933b197343b4b7b"
            },
            "downloads": -1,
            "filename": "audio_files_organizer_iphone-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6161ab044d5f1d0f94a40e39a8b7d84f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 9328,
            "upload_time": "2024-11-21T20:21:07",
            "upload_time_iso_8601": "2024-11-21T20:21:07.495007Z",
            "url": "https://files.pythonhosted.org/packages/2b/f3/5428755a4b16de03cbc7645165e2a5a76ee75551d36da6b05cd318977996/audio_files_organizer_iphone-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "99782c9028bcc553b4271d81a0d1f9531c19c4da532a5a67997fdfb052ab532e",
                "md5": "99e642a6f6fa945d75b3ee04a8f67bb6",
                "sha256": "58d10a0c220b58145b452dd68f8ce47627f0cde5e71b865db7f650b5b065a9ad"
            },
            "downloads": -1,
            "filename": "audio_files_organizer_iphone-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "99e642a6f6fa945d75b3ee04a8f67bb6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8814,
            "upload_time": "2024-11-21T20:21:09",
            "upload_time_iso_8601": "2024-11-21T20:21:09.221731Z",
            "url": "https://files.pythonhosted.org/packages/99/78/2c9028bcc553b4271d81a0d1f9531c19c4da532a5a67997fdfb052ab532e/audio_files_organizer_iphone-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-21 20:21:09",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "David-Sandeep",
    "github_project": "audio-files-organizer-iphone",
    "github_not_found": true,
    "lcname": "audio-files-organizer-iphone"
}
        
Elapsed time: 4.90533s