Skip to content

Instantly share code, notes, and snippets.

@se7enack
Last active December 22, 2024 22:50
Show Gist options
  • Select an option

  • Save se7enack/ce1b2166a13d665db17adb151e1fd3f0 to your computer and use it in GitHub Desktop.

Select an option

Save se7enack/ce1b2166a13d665db17adb151e1fd3f0 to your computer and use it in GitHub Desktop.

Revisions

  1. se7enack revised this gist Dec 22, 2024. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions bulk_file_rename.py
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,7 @@
    string = ".720p.WEB.h264-ETHEL"

    # Get the current working directory
    #cwd = os.getcwd()
    cwd = "/Users/user/Desktop/w2wtest"
    cwd = os.getcwd()

    # Get a list of all the files in the current directory
    files = os.listdir(cwd)
    @@ -18,4 +17,4 @@
    new_name = file.replace(string, "")

    # Rename the file
    os.rename(old_name, new_name)
    os.rename(old_name, new_name)
  2. se7enack created this gist Dec 22, 2024.
    21 changes: 21 additions & 0 deletions bulk_file_rename.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    #!/usr/bin/env python3

    import os

    string = ".720p.WEB.h264-ETHEL"

    # Get the current working directory
    #cwd = os.getcwd()
    cwd = "/Users/user/Desktop/w2wtest"

    # Get a list of all the files in the current directory
    files = os.listdir(cwd)

    # Iterate over the files and rename them
    for file in files:
    # Get the old and new names of the file
    old_name = file
    new_name = file.replace(string, "")

    # Rename the file
    os.rename(old_name, new_name)