Skip to content

Instantly share code, notes, and snippets.

@florian-glombik
Last active October 2, 2024 23:28
Show Gist options
  • Save florian-glombik/639cd30b48ed5523e6484fe222d661af to your computer and use it in GitHub Desktop.
Save florian-glombik/639cd30b48ed5523e6484fe222d661af to your computer and use it in GitHub Desktop.
This python script renames .mov files to .mp4 files, which can be useful when exporting videos from the iOS photos app. You will need to adjust the path variable to the path where your pictures are stored.
import os
import glob
import logging
path_to_mov_files_to_be_renamed = '/path/to/your/movFiles'
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)s: %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p')
def rename_mov_files_to_mp4(path):
os.chdir(path)
mov_files = glob.glob('*.mov')
logging.info(f"Total number of files to be renamed: {len(mov_files)}")
renamed_files_count = 0
for mov_file in mov_files:
logging.info(f"\tRenaming file {renamed_files_count}: {mov_file}")
# Split the file into name and extension
base = os.path.splitext(mov_file)[0]
# Rename the file
new_name = base + '.mp4'
os.rename(mov_file, new_name)
logging.info(f"\t\tRenamed file: {new_name}\n")
renamed_files_count += 1
logging.info(f"All {renamed_files_count} files have been renamed.")
if __name__ == '__main__':
rename_mov_files_to_mp4(path_to_mov_files_to_be_renamed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment