The best way to convert files on your computer, be it .pdf to .png, .pdf to .docx, .png to .ico, or anything you can imagine.

Overview

The-BEST-way-to-convert-files

The best way to convert files on your computer, be it .pdf to .png, .pdf to .docx, .png to .ico, or anything you can imagine.

Goal?

Are you sick and tired of going to an online website to convert certain documents?

The tedious process, and the length you have to go through has driven me up the wall.

I made a gist a while ago explaining how you can do this through the CLI, which don't get me wrong is a great way to do it if you have a terminal on hand. But I found an even better way to do this.

I will be using the same script/converter in the gist mentioned above just for simplicity sake, the same applies to ANY file conversion you can think of.

How?

Context Menus.

NOTE This is WINDOWS SPECIFIC!

How can we add to the context menu? The answer is in EcMenu. It's free, and it works super well!

Let's go over how to set up a python script and run that through the Context Menu.

Setup

Any conversion script has these requirements:

What do we need?

  1. Convert file from something TO something else.
    • This doesn't need to be spesfically .png to .ico. It can be a fairly complex conversion, say .pdf to images.
  2. Input file
    • We need to get the input file we want to convert, the rest is handled by the script.
  3. Current directory
    • We need the directory of the file you want to convert. This way the program works no matter where the file is located. Alternativly you can set a CONSTANT output directory if you so please in the script itself. For this example we will be working in the directory of where the file is located itself.

Setting up python script

main.py

# Required libraries
import sys, os

def convert(file_name: str, output_dir: str):
    ...

# Get the file name
file_name: str = sys.argv[-1].split('\\')[-1]

# Get directory of where the file is located 
directory_of_file: str = os.getcwd()

# Start the conversion process
convert(file_name, directory_of_file)

How do we run this? Why are we not using argparse?

To run this script we do: python main.py this_is_my_file.txt

We don't use areparse because we can't directly add arguments to the context menu. argparse we need a -f this_is_my_file.txt to specify the file, but we don't need that, we know we input only one file, so we can just use sys.

sys.argv[-1].split('\\')[-1] This gives us the file that you right clicked on.

We then need compile the python script using:

pyinstaller -F pdftoword.py

In this script i'm using the terminal for feedback, you can use what ever you want, you can use tkinter, qt, or not give anyfeed back at all, to do that simply use:

pyinstaller -F --noconsole pdftoword.py

The .exe will be in a dist directory where you the python script is located.

Addying the python script to the context menu.

  1. Get EcMenu
  2. Go to list Editor

image

  1. Scroll down to File Context Menu

image

  1. Make sure you select File Context Menu and press Add New and Browse to where the .exe file is located.

image

  1. Press Save Changes

image

  1. Make sure it's checked!

image

  1. Press Apply Changes

image

And your done. Right click on any file and you should see it!

Summary

This is just a 'quality of life' solution. You can go above and beyond with this method of converting files, you can add a whole suite of file conversions if you so want too.

Owner
JareBear
Hi there! I hope your having a wonderful day. I mainly code in python and use Unity for mobile applications. I have a some projects written in snek language
JareBear
A bot discord that can create directories, file, rename, move, navigate throw directories etc....

File Manager Discord What is the purpose of this program ? This program is made for a Discord bot. Its purpose is to organize the messages sent in a c

1 Feb 02, 2022
Python code snippets for extracting PDB codes from .fasta files

Python_snippets_for_bioinformatics Python code snippets for extracting PDB codes from .fasta files If you have a single .fasta file for all protein se

Sofi-Mukhtar 3 Feb 09, 2022
A simple tool to find and replace all the matches of a regular expression in file(s).

FindREp A simple tool to find and replace all the matches of a regular expression in file(s). You can either select the file(s) directly or select a f

Biraj 5 Oct 18, 2022
A JupyterLab extension that allows opening files and directories with external desktop applications.

A JupyterLab extension that allows opening files and directories with external desktop applications.

martinRenou 0 Oct 14, 2021
CleverCSV is a Python package for handling messy CSV files.

CleverCSV is a Python package for handling messy CSV files. It provides a drop-in replacement for the builtin CSV module with improved dialect detection, and comes with a handy command line applicati

The Alan Turing Institute 1k Dec 19, 2022
Pti-file-format - Reverse engineering the Polyend Tracker instrument file format

pti-file-format Reverse engineering the Polyend Tracker instrument file format.

Jaap Roes 14 Dec 30, 2022
A file utility for accessing both local and remote files through a unified interface.

A file utility for accessing both local and remote files through a unified interface.

AI2 19 Nov 16, 2022
A Python script to organize your files in a given directory.

File-Organizer A Python script to organize your files in a given directory. It organizes your files based on the file extension and moves them into sp

Imira Randeniya 1 Sep 11, 2022
An universal file format tool kit. At present will handle the ico format problem.

An universal file format tool kit. At present will handle the ico format problem.

Sadam·Sadik 1 Dec 26, 2021
This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it

This python project contains a class FileProcessor which allows one to grab a file and get some meta data and header information from it. In the current state, it outputs a PrettyTable to txt file as

Joshua Wren 1 Nov 09, 2021
Get Your TXT File Length !.

TXTLen Get Your TXT File Length !. Hi 👋 , I'm Alireza A Python Developer Boy 🔭 I’m currently working on my C# projects 🌱 I’m currently Learning CSh

Alireza Hasanzadeh 1 Jan 06, 2022
A python script generate password files in plain text

KeePass (or any desktop pw manager?) Helper WARNING: This script will generate password files in plain text. ITS NOT SECURE. I needed help remembering

Eric Thomas 1 Nov 21, 2021
Instant Fuzzy File Search for Alfred

List all the files inside a folder using fd, and instantly fuzzy-search through all of them using fzf, all from inside Alfred with a single keyword: fzf.

Mr. Pennyworth 37 Nov 30, 2022
Singer is an open source standard for moving data between databases, web APIs, files, queues, and just about anything else you can think of.

Singer is an open source standard for moving data between databases, web APIs, files, queues, and just about anything else you can think of. Th

Singer 1.1k Jan 05, 2023
RMfuse provides access to your reMarkable Cloud files in the form of a FUSE filesystem

RMfuse provides access to your reMarkable Cloud files in the form of a FUSE filesystem. These files are exposed either in their original format, or as PDF files that contain your annotations. This le

Robert Schroll 82 Nov 24, 2022
Organizer is a python program that organizes your downloads folder

Organizer Organizer is a python program that organizes your downloads folder, it can run as a service and so will start along with the system, and the

Gustavo 2 Oct 18, 2021
BOOTH宛先印刷用CSVから色々な便利なリストを作成してCSVで出力するプログラムです。

BOOTH注文リスト作成スクリプト このPythonスクリプトは、BOOTHの「宛名印刷用CSV」から、 未発送の注文 今月の注文 特定期間の注文 を抽出した上で、各注文を商品毎に一覧化したCSVとして出力するスクリプトです。 簡単な使い方 ダウンロード 通常は、Relaseから、booth_ord

hinananoha 1 Nov 28, 2021
pydicom - Read, modify and write DICOM files with python code

pydicom is a pure Python package for working with DICOM files. It lets you read, modify and write DICOM data in an easy "pythonic" way.

DICOM in Python 1.5k Jan 04, 2023
Transforme rapidamente seu arquivo CSV (de qualquer tamanho) para SQL de forma rápida.

Transformador de CSV para SQL Transforme rapidamente seu arquivo CSV (de qualquer tamanho) para SQL de forma rápida, e com isso insira seus dados usan

William Rodrigues 4 Oct 17, 2022
The best way to convert files on your computer, be it .pdf to .png, .pdf to .docx, .png to .ico, or anything you can imagine.

The best way to convert files on your computer, be it .pdf to .png, .pdf to .docx, .png to .ico, or anything you can imagine.

JareBear 2 Nov 20, 2021