Skip to content

Commit

Permalink
Update batch-renamer to version 1.0.3 & cleaned source code
Browse files Browse the repository at this point in the history
  • Loading branch information
5kyc0d3r committed Mar 18, 2017
1 parent d28a4da commit 8e202f4
Show file tree
Hide file tree
Showing 89 changed files with 186 additions and 1,032 deletions.
100 changes: 100 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject

# Rope project settings
.ropeproject

# Idea (PyCharm) project configuration
.idea/

# Script directories
scripts/
12 changes: 2 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
language: python
python:
- "2.7"

install:
- sudo apt-get install python-tk
- sudo pip install nvpy
- sudo apt-get install python-stdeb fakeroot python-all


script:
- cd deb-package-builder
- sudo python setup.py --command-packages=stdeb.command bdist_deb
- sudo dpkg -i deb_dist/python-batch-renamer-cli_1.0.2b3-1_all.deb

- sudo python setup.py install
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2016 Girish Oemrawsingh
Copyright (c) 2017 Girish Oemrawsingh

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file removed Linux Build/_codecs_cn.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_codecs_hk.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_codecs_iso2022.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_codecs_jp.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_codecs_kr.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_codecs_tw.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/_multibytecodec.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/batch-renamer-cli
Binary file not shown.
Binary file removed Linux Build/bz2.x86_64-linux-gnu.so
Binary file not shown.
Binary file removed Linux Build/libpython2.7.so.1.0
Binary file not shown.
Binary file removed Linux Build/library.zip
Binary file not shown.
37 changes: 14 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,35 @@
## Batch Renamer
[![Build Status](https://travis-ci.org/darko3/batch-renamer.svg?branch=master)](https://travis-ci.org/darko3/batch-renamer) [![Packagist](https://img.shields.io/badge/python-2.7-yellow.svg)](https://www.python.org) [![Packagist](https://img.shields.io/packagist/l/doctrine/orm.svg?maxAge=2592000)](https://github.com/darko3/batch-renamer/blob/master/LICENSE) [![Packagist](https://img.shields.io/badge/OS-Linux%20|%20Windows-orange.svg)](#)

![alt text](http://i.imgur.com/xQL2Zbi.png "Screenshot from v1.0.2b")
![alt text](http://i.imgur.com/YhuX94a.png "Screenshot from v1.0.3")


An easy to use python script for quickly renaming multiple files ending with incrementing numbers.

A script written in Python 2.7 to batch rename files in a folder with the specified name ending with incrementing numbers.

*The code will be rewritten in February 2017*
## Installation

## Releases
* Batch File Renamer v1.0.1
* Batch File Renamer v1.0.2a
* Batch File Renamer v1.0.2b
1. Clone the git repository

Latest release: v1.0.2b
`$ git clone https://github.com/darko3/batch-renamer.git`

You can find all releases on the releases page: [https://github.com/darko3/batch-renamer/releases](https://github.com/darko3/batch-renamer/releases)
2. Change directory into the git repository

## Installation
> *Only Ubuntu Xenial, Trusty, Vivid and Wily are supported if you're installing from a PPA
`$ cd batch-renamer`

3rd party modules used:
* colorama
3. Run setup.py

colorama can be installed with pip with the following command:
`$ sudo python setup.py install`

`pip install colorama`
4. If all the above commands were successful, you should now be able to run the script from the commandline

**colorama is only needed if you're going to be building with cx_Freeze or if you're running the program from the source code (*.py files).**

Please see https://darko3.github.io/batch-renamer/installation for installation inctructions.
`$ batch-rename`

## Requirements

**Update: Windows and Linux installers are now compiled, see https://github.com/darko3/batch-renamer/releases for the binary files.**

* Python 2.x - 3.x
* Colorama module

* Python 2.7 (optional, only needed if you are going to be running from source)
* A Linux or Windows Operating System
You can install colorama with `$ sudo pip install colorama`.

## License
This project is licensed under the terms of the MIT license.
Expand Down
Binary file removed Windows Build/_ctypes.pyd
Binary file not shown.
Binary file removed Windows Build/batch-renamer-cli.exe
Binary file not shown.
Binary file removed Windows Build/bz2.pyd
Binary file not shown.
Binary file removed Windows Build/library.zip
Binary file not shown.
Binary file removed Windows Build/python27.dll
Binary file not shown.
Binary file removed Windows Build/unicodedata.pyd
Binary file not shown.
50 changes: 25 additions & 25 deletions batch-renamer-cli.py → batch-rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
MIT License
Copyright (c) 2016 Girish Oemrawsingh
Copyright (c) 2017 Girish Oemrawsingh
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -24,28 +24,29 @@
SOFTWARE.
"""

# Import required modules
import os
import sys
import time
import getopt

# This is a 3rd party module, it's needed for colors in the windows commandline
# If you don't have it, you can install it with pip
# pip install colorama
# $ pip install colorama
import colorama

# import the color module I wrote for my projects
from color import Color as tcolor
from color import textType as ttype
from batch_renamer_cli import Color as TextColor
from batch_renamer_cli import textType as TextType

version = '1.0.2b'
github_project_page = ttype.bold + tcolor.green + 'https://github.com/darko3/batch-renamer' + tcolor.white
version = '1.0.3'
github_project_page = TextType.bold + TextColor.green + 'https://github.com/darko3/batch-renamer' + TextColor.white
usage = """
Batch File Renamer %s - (C) 2016 Girish Oemrawsingh
Batch File Renamer %s - (C) 2017 Girish Oemrawsingh
View this project on Github: %s
usage: ./batch-renamer-cli.py [options]
usage: ./batch-rename.py [options]
Options:
Expand All @@ -55,6 +56,9 @@
""" % (version, github_project_page)

rename_warning = """PLEASE CHECK IF THE FOLDER PATH AND NEW NAME IS CORRECT BECAUSE YOU CAN EASILY RENAME FILES IN ANY
FOLDER YOU DID NOT INTEND TO\nPRESS [ENTER] TO CONTINUE OR CTRL + C TO EXIT\n"""


def main(folder, new_name):

Expand Down Expand Up @@ -89,6 +93,7 @@ def main(folder, new_name):
else:
rename_files(folder, new_name)


def rename_files(folder_path, new_name):

file_counter = 0
Expand All @@ -97,21 +102,16 @@ def rename_files(folder_path, new_name):
print("Folder path: %s\n" % folder_path)

try:
raw_input(ttype.bold + tcolor.red + """PLEASE CHECK IF THE FOLDER PATH AND NEW NAME IS CORRECT
BECAUSE YOU CAN EASILY RENAME FILES IN ANY FOLDER YOU DID NOT INTEND TO\n
PRESS [ENTER] TO CONTINUE OR CTRL + C TO EXIT\n""" + tcolor.white)
raw_input(TextType.bold + TextColor.red + rename_warning + TextColor.white)

except NameError:
input(ttype.bold + tcolor.red + """PLEASE CHECK IF THE FOLDER PATH AND NEW NAME IS CORRECT
BECAUSE YOU CAN EASILY RENAME FILES IN ANY FOLDER YOU DID NOT INTEND TO\n
PRESS [ENTER] TO CONTINUE OR CTRL + C TO EXIT\n""" + tcolor.white)
input(TextType.bold + TextColor.red + rename_warning + TextColor.white)

except KeyboardInterrupt:
print("\nThank you for using Batch File Renamer by Girish Oemrawsingh.")
print("You can view this project on Github: %s" % github_project_page)
sys.exit(2)


print("\n\nThank you for using Batch File Renamer by Girish Oemrawsingh.")
print("You can view this project on Github: %s\n" % github_project_page)
sys.exit(1)

start = time.time()

for root, dirs, files in os.walk(folder_path):
Expand All @@ -124,16 +124,16 @@ def rename_files(folder_path, new_name):
file_path = "%s/%s" % (root, f)
print("Renaming %s" % file_path)
ext = os.path.splitext(new_name)[1]
fname = os.path.splitext(new_name)[0]
os.rename(file_path, "%s/%s %s%s" % (root, fname, file_counter, ext))
file_name = os.path.splitext(new_name)[0]
os.rename(file_path, "%s/%s-%s%s" % (root, file_name, file_counter, ext))

end = time.time()
total_time = end - start
print("\nFinished renaming %d files with a total time of %f seconds." % (file_counter, total_time))
print("Finished renaming %d files with a total time of %f seconds.\n" % (file_counter, total_time))


if __name__ == "__main__":
folder = ''
new_name = ''
# folder = ''
# new_name = ''
colorama.init()
main(folder, new_name)
main(folder='', new_name='')
5 changes: 5 additions & 0 deletions batch_renamer_cli/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/python

# __init__.py file for batch-renamer-cli package

from .color import *
16 changes: 16 additions & 0 deletions batch_renamer_cli/color.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# A simple color module I wrote for my projects
# Feel free to copy this script and use it for your own projects!


class Color:
purple = '\033[95m'
blue = '\033[94m'
green = '\033[92m'
yellow = '\033[93m'
red = '\033[91m'
white = '\033[0m'


class textType:
bold = '\033[1m'
underline = '\033[4m'
22 changes: 0 additions & 22 deletions build_exe.py

This file was deleted.

15 changes: 0 additions & 15 deletions color.py

This file was deleted.

Binary file removed deb-package-builder/batch-renamer-cli-1.0.2b3.tar.gz
Binary file not shown.
11 changes: 0 additions & 11 deletions deb-package-builder/batch_renamer_cli.egg-info/PKG-INFO

This file was deleted.

9 changes: 0 additions & 9 deletions deb-package-builder/batch_renamer_cli.egg-info/SOURCES.txt

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion deb-package-builder/br/__init__.py

This file was deleted.

Loading

0 comments on commit 8e202f4

Please sign in to comment.