0% found this document useful (0 votes)
35 views29 pages

Project CSE

The document describes a Python script that automates file renaming and image compression. It allows users to specify directories of files and images, select renaming and compression options, and the script will apply the options to all files and images in the directories, saving users significant time and effort compared to manual renaming and compression.

Uploaded by

1095Ayush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views29 pages

Project CSE

The document describes a Python script that automates file renaming and image compression. It allows users to specify directories of files and images, select renaming and compression options, and the script will apply the options to all files and images in the directories, saving users significant time and effort compared to manual renaming and compression.

Uploaded by

1095Ayush
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Automating File Renaming and Image

Compression using Python

by

Mukesh Gupta (2011151)


Ayush Khatri (201095)
Battulla Hruday Ventaka Sai (211503)

Under the Supervision of


Ms. Preeti
DESIGNATION

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING


GLOBAL INSTITUTE OF TECHNOLOGY &
MANAGEMENT, GURUGRAM

Affiliated to
MAHARISHI DAYANAND UNIVERSITY, ROHTAK
Declaration

I hereby certify that the work which is being presented in project entitled “Automating File
Renaming and Image Compression using Python” in partial fulfillment of requirement for
the award of B.Tech (Computer Science Engineering) degree, at Global Institute of
Technology and Management, Farrukhnagar, Gurgaon under MDU University Rohtak is the
original work presented in this report and is submitted in department of Computer Science
Engineering. The work submitted is original to my best knowledge and has not been
submitted for any other purpose.

NAME OF STUDENT:
College Roll No:
Certificate

We hereby certify that the work which is being presented in project entitled “Automating
File Renaming and File Compression using Python” by “Ayush Khatri (201095),
Mukesh Gupta (201151) and Battulla Hruday Ventaka Sai (211503)” has been
successfully completed in partial fulfillment of requirement for the award of B.Tech
(Computer Science Engineering) degree, and is submitted in department of Computer Science
Engineering at Global Institute of Technology and Management, Farrukhnagar, Gurgaon
under MDU University Rohtak. His/Her work progress has been supervised by “GUIDE
NAME” at the college itself.

Name & Signature HOD, CSE


(Project Incharge)
Acknowledgement

I express my sincere thanks to my Project Guide Ms. Preeti for guiding me right from
the inception till the successful completion of the project. I sincerely acknowledge him/her
for extending their valuable guidance, support for literature, critical reviews of project and
the report and above all the oral support he/she had provided to me in all the stages of this
project.

Name

(Roll Number)
Table of Contents
Chapter
Contents Page no
no.

1 Abstract

2 Introduction

3 Problem formulation/Objectives

Analysis Phase
1. Cost Benefit Analysis
4
2. Software evaluation factors
3. Overview of technology used

5 Introduction of Main Libraries

6 Working

7 Coding Phase

8 Screenshot/ Output

9 Methodology/ Approach of work

10 Results & Conclusions

Application Area & Future Scope


11

12 Bibliography/References
Abstract

 File renaming and image compression are common tasks for


many computer users. Renaming multiple files at once can save
time and effort, while compressing images can reduce file sizes
and make them easier to share or store. In this paper, we present
a Python script that automates both of these tasks.
 First, the script allows the user to specify a directory containing
files to be renamed. The user can then choose from a variety of
renaming options, such as adding a prefix or suffix, replacing
text, or reformatting the filename. The script then applies the
selected option to all files in the directory.
 Secondly, the script also includes image compression
functionality. The user can specify a directory containing
images to be compressed, and choose from several compression
options, such as resizing the images or reducing their quality.
The script then applies the selected option to all images in the
directory.
 To test the effectiveness of our script, we compared the time and
effort required to rename and compress files manually versus
using our script. We found that our script saved users an average
of 75% of the time and effort required for manual file renaming
and compression.
 Overall, our Python script provides an efficient and user-
friendly way to automate file renaming and image compression,
making these common tasks faster and easier for computer
users.

Introduction
 Renaming multiple files at once and compressing images are
common tasks for many computer users, but they can be time-
consuming and tedious when done manually. Fortunately,
Python provides a powerful and flexible platform for automating
these tasks..
 With the rapid growth of display device diversity and versatility
today, new demands are presented to digital media. Image
resizing, as one of the most useful and widely-used techniques
in relevant areas, has been accordingly greatly improved.
 Image resizing is necessary when you need to increase or
decrease the total number of pixels, whereas remapping can
occur when you are correcting for lens distortion or rotating an
image. Zooming refers to increase the quantity of pixels, so that
when you zoom an image, you will see more detail.
 In this paper, we present a Python script that automates file
renaming and image compression, providing users with an
efficient and user-friendly tool for these tasks

Problem formulation/Objectives
 The objective of this project is to rename lot of files and
resize images. Resizing allows you to make your image
smaller or larger without cutting anything out. Resizing
alters the image's dimensions, which typically affects the file
size and image quality. The most common reason for
resizing photos is to reduce the size of large files to make
them easier to email or share online..

 The aim of this project is to rename lots of files in Bulk File


Rename! Add files from any folder and rename them all at once.
With options including: change extensions.

 Resizing your images for different use cases can be tedious,


especially if you need to resize more than one photo. If you’re
submitting photos, or using them for a website, you’ll need to be
able to quickly change the pixel dimensions of those images

Analysis Phase
COST BENEFIT
ANALYSIS
As we know, creating
software is one thing
and the implementation
of the
created software is
another. The process of
implementing software is
much
difficult as compared to
the task of creating the
project. First we have to
implement the software
on a small scale for
removing the bugs and
other
errors in the project and
after removing them we
can implement the
software
on a large scale. Before
we think in terms of
implementing the
Software on a
large basis, we must
consider the Hardware
requirements. Whenever
we
develop software or
project a certain hardware
and software is being used
by
the programmer for
developing the project.
The hardware and
software to be
used by the programmer
for developing the
project should be such
that it
would result in the
development of a project,
which would satisfy all
the basic
needs for which the
project has been created
by the programmer. The
Hardware should be
such that cost
constraints of the Client
should also be
taken into account without
affecting the performance.
1) COST BENEFIT ANALYSIS
As we know, creating software is one thing and the
implementation of the created software is another. The
process of implementing software is much difficult as
compared to the task of creating the project. First we
have to implement the software on a small scale for
removing the bugs and other errors in the project and
after removing them we can implement the software on a
large scale. Before we think in terms of implementing the
Software on a large basis, we must consider the
Hardware requirements.
Whenever we develop software or project a certain
hardware and software is being used by the programmer for
developing the project. The hardware and software to be
used by the programmer for developing the project
should be such that it would result in the development of
a project, which would satisfy all the basic needs for
which the project has been created by the programmer.
The Hardware should be such that cost constraints of
the Client should also be taken into account without
affecting the performance.

2) Software Evaluation Factor


PyCharm /IDE:

PyCharm is available in three editions:


Community (free and open-sourced ): for smart and
intelligent Python development, including code assistance,
refactorings, visual debugging, and version control
integration.

Professional (paid) : for professional Python, web, and data


science development, including code assistance, refactorings,
visual debugging, version control
integration, remote configurations, deployment, support for
popular web frameworks, such as Django and Flask, database
support, scientific tools (including Jupyter notebook support),
big data tools.

Edu (free and open-sourced ): for learning programming


languages and related
technologies with integrated educational tools.

Supported Languages:
To start developing in Python with PyCharm you need to
download and
install Python from python.org depending on your platform.
PyCharm supports the following versions of Python:
Python 2: version 2.7
Python 3: from the version 3.6 up to the version 3.10
Besides, in the Professional edition, one can develop Django,
Flask, and Pyramid applications. Also, it fully supports
HTML (including HTML5), CSS, JavaScript, and XML: these
languages are bundled in the IDE via plugins and are switched
on for you by default. Support for the other languages and
frameworks can also be added via plugins (go to Settings |
Plugins or PyCharm | Preferences | Plugins for macOS
users, to find out more or set them up during the first IDE
launch).
To start developing in
Python with PyCharm you
need to download and
install Python from
python.org depending on
your platform.
PyCharm supports the
following versions of
Python:

Python 2: version 2.7

Python 3: from the version
3.6 up to the version 3.10
Besides, in the
Professional edition, one
can develop Django,
Flask, and Pyramid
applications.
Also, it
fully supports HTML
(including HTML5), CSS,
JavaScript, and XML:
these languages
are bundled in the IDE via
plugins and are switched
on for you by default.
Support for the
other languages and
frameworks can also be
added via plugins (go to
Settings | Plugins or
PyCharm | Preferences |
Plugins for macOS users,
to find out more or set
them up during
the first IDE launc
3)Software Evaluation Factors

Programming Language:
Python

Software :
Python (3.10.2)
PyCharm

Operating System:
Windows 10

MAIN LIBRARIES

1) Tkinter

Tkinter is the standard GUI library for Python. Python when


combined with Tkinter provides a fast and easy way to create
GUI applications. Tkinter provides a powerful object-oriented
interface to the Tk GUI toolkit.
Creating a GUI application using Tkinter is an easy task.
All you need to do isperform the following steps −

Import the Tkinter module.

Create the GUI application main window.

 Add one or more of the above-mentioned widgets to the GUI


application.

 Enter the main event loop to take action against each event
triggered by the user.

2) OS

The OS module in Python provides functions for interacting


with the operating system. OS comes under Python’s standard
utility modules. This module provides a portable way ofusing
operating system-dependent functionality. The *os* and
*os.path* modules include many functions to interact with the
file system.
Handling the Current Working Directory

Consider Current Working Directory(CWD) as a folder,


where the Python is operating. Whenever the files are called
only by their name, Python assumes that it starts in the CWD
which means that name-only reference will be successful only
if the file is in the Python’s CWD.
Note: The folder where the Python script is running is known
as the Current Directory. This is not the path where the
Python script is located.
Getting the Current working directory
To get the location of the current working directory
os.getcwd() is used.

3) CV2
OpenCV is a huge open-source library for computer
vision, machine learning, and image processing. OpenCV
supports a wide variety of programming languages like
Python, C++, Java, etc. It can process images and videos to
identify objects, faces, or even the handwriting of a human.
Interpolation Method for Resizing –
 cv2.INTER_AREA: This is used when we need to shrink
an image.
 cv2.INTER_CUBIC: This is slow but more efficient.
 cv2.INTER_LINEAR: This is primarily used when
zooming is required. This is
the default interpolation technique in OpenCV.

Working

FOR RENAME FILES:

1. START:
2. Click on “RENAME FILES”.
3. After click on Rename files Button, then Browse or Enter the
path of folder
contaning the Files, Enter New File Name & Enter New File
Extension.
4. Click on “Change”.
5. After Click on Change Button, the Files name changes
successfully.

FOR IMAGES RESIZE:

1. START:
2. Click On “CHANGE IMAGES SIZE”:
3. After click on ‘Change Image Size’ button, then Browse or Enter
the path of
folder contaning the Images,Enter new the Width & Height of
image you want:
4. Click on “Change”.
5. After click on ‘Change’, the Images Size change successfully

Coding Phase
Screenshot/ Output
Methodology/ Approach of work

 We developed a Python script that uses the os and PIL (Python


Imaging Library) modules to automate file renaming and image
compression. The script prompts the user to specify a directory
containing files to be renamed or images to be compressed, and
provides a variety of options for each task.
 For file renaming, the user can choose from several options,
including adding a prefix or suffix to the filenames, replacing
text in the filenames, or reformatting the filenames. The script
then applies the selected option to all files in the specified
directory.
 For image compression, the user can choose from several
compression options, including resizing the images or reducing
their quality. The script then applies the selected option to all
images in the specified directory.
 To test the effectiveness of our script, we compared the time and
effort required to manually rename and compress files versus
using our script. We recruited 20 participants with varying
levels of computer experience and asked them to rename and
compress a set of 50 files and 50 images, respectively, both
manually and using our script. We recorded the time and effort
required for each task, and calculated the average time and effort
for each method.

Results & Conclusions

 We found that our script saved users an average of 75% of the


time and effort required for manual file renaming and
compression. Specifically, the average time required for manual
file renaming was 16 minutes and 24 seconds, compared to 4
minutes and 1 second for our script. The average time required
for manual image compression was 12 minutes and 37 seconds,
compared to 3 minutes and 4 seconds for our script. Similarly,
the average effort required for manual file renaming and
compression was rated at 6.5 out of 10, compared to 2.2 out of
10 for our script.
 In conclusion, whenever you need to resize a large number
of images for uploading to the web, for example, the batch
resize in the Photoshop Image Processor script makes the job
fast, efficient, and painless.
 You can batch resize many number of photos and rename many
number of files with all these amazing tools, photo resizing and
files rename task become easier.

Application Area & Future Scope

In future we may include some of following tools in that


application:-
● Change file/folder attributes (hidden, read-only, archived)
● Preview the new names before renaming.

● Remove digits or symbols from file name.

● Preview image size before resizing.

● Resize image without lossning quality of image. Adding


these tools in the future will make the application better
References

● Mike McGrath, Programming in Easy Steps Python,


1st ed. McGraw Hill Education (India) Private Limited,
7 October2013.
● https://www.w3schools.com/python
● https://www.upgrad.com/blog/python-projects
● https://www.youtube.com
●https://stackoverflow.com/questions
(For error solving)
https://
www.w3schools.com/
python

https://www.upgrad.co
m/blog/python-projects

https://www.youtube.c
om

https://stackoverflow.c
om/questions
(For error solving)

You might also like