Skip to content

Instantly share code, notes, and snippets.

@florian-glombik
Last active June 21, 2024 04:05
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
path_to_mov_files_to_be_renamed = '/path/to/your/movFiles'
def rename_mov_files_to_mp4(path):
os.chdir(path)
mov_files = glob.glob('*.mov')
print(f"Total number of files to be renamed: {len(mov_files)}")
renamed_files_count = 0
for mov_file in mov_files:
print(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)
print(f"\t\tRenamed file: {new_name}\n")
renamed_files_count += 1
print(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