GithubHelp home page GithubHelp logo

file_renamer's Introduction

FileReNamer

Effortlessly rename files in bulk with this Python program. Created to simplify the task of renaming a lot of files, it was written in the time it would have taken to manually fix the filename typo in those 2000 images I just exported...

Getting started

# Clone the repo 
git clone https://github.com/TurbulentRice/file_renamer.git
cd file_renamer/

# Use a virtual environment (optional)
python -m venv venv
source venv/bin/activate

# Install package in edit mode
pip install -e .

# Run the console script, optionally specifying target directory
rename-files [--target TARGET_DIRECTORY]

# Alternatively, run the script as a module
python -m file_renamer [--target TARGET_DIRECTORY]

# NOTE: TARGET_DIRECTORY path can be relative

Usage

Search and replace

ex. Replace occurences of "IMG" with "PHOTO", and "_sm" with nothing:

your_folder/
|-- IMG_0001_sm.png -> PHOTO_0001.png
|-- IMG_0002_sm.png -> PHOTO_0002.png
|-- IMG_0003_sm.png -> PHOTO_0003.png
|-- ...

Add prefixes

ex. Add "IMG_" to the beginning of each filename:

your_folder/
|-- 0001.png -> IMG_0001.png
|-- 0002.png -> IMG_0002.png
|-- 0003.png -> IMG_0003.png
|-- ...

Add sufixes

ex. Add "_sm" to end of each filename:

your_folder/
|-- IMG_0001.png -> IMG_0001_sm.png
|-- IMG_0002.png -> IMG_0002_sm.png
|-- IMG_0003.png -> IMG_0003_sm.png
|-- ...

Enumerate (WIP)

Add numbers to filenames:

your_folder/
|-- logo.png        -> 01_logo.png
|-- background.png  -> 02_background.png
|-- header.png      -> 03_header.png
|-- ...

Add from file (WIP)

Use some content from within the file that is being changed to determine its new name.

For example, say you had a folder like this:

your_folder/
|-- address_file01.txt
|-- address_file02.txt
|-- address_file03.txt
|-- ...

Where each address_file.txt contains a zipcode somehwere in its contents, and you want to organize the files by those zipcode values. Using regular expressions, we can search the file contents for a zipcode, and rename them so they look like this:

your_folder/
|-- 01234.txt
|-- 43210.txt
|-- 99999.txt
|-- ...

file_renamer's People

Contributors

turbulentrice avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.