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.

You might also like...
PaddingZip - a tool that you can craft a zip file that contains the padding characters between the file content.
PaddingZip - a tool that you can craft a zip file that contains the padding characters between the file content.

PaddingZip - a tool that you can craft a zip file that contains the padding characters between the file content.

A python script to convert an ucompressed Gnucash XML file to a text file for Ledger and hledger.

README 1 gnucash2ledger gnucash2ledger is a Python script based on the Github Gist by nonducor (nonducor/gcash2ledger.py). This Python script will tak

Various converters to convert value sets from CSV to JSON, etc.

ValueSet Converters Tools for converting value sets in different formats. Such as converting extensional value sets in CSV format to JSON format able

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 lets you manage files in the reMarkable Cloud using the same tools you use on your local system.

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

Sheet Data Image/PDF-to-CSV Converter

Sheet Data Image/PDF-to-CSV Converter

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.

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

This is a junk file creator tool which creates junk files in Internal Storage

This is a junk file creator tool which creates junk files in Internal Storage

Maltego transforms to pivot between PE files based on their VirusTotal codeblocks
Maltego transforms to pivot between PE files based on their VirusTotal codeblocks

VirusTotal Codeblocks Maltego Transforms Introduction These Maltego transforms allow you to pivot between different PE files based on codeblocks they

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
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
csv2ir is a script to convert ir .csv files to .ir files for the flipper.

csv2ir csv2ir is a script to convert ir .csv files to .ir files for the flipper. For a repo of .ir files, please see https://github.com/logickworkshop

Alex 38 Dec 31, 2022
Dragon Age: Origins toolset to extract/build .erf files, patch language-specific .dlg files, and view the contents of files in the ERF or GFF format

DAOTools This is a set of tools for Dragon Age: Origins modding. It can patch the text lines of .dlg files, extract and build an .erf file, and view t

null 8 Dec 6, 2022
This program can help you to move and rename many files at once

This program can help you to rename and save many files in a folder in seconds, but don't give the same name to files, it can delete both files.

João Assalim 1 Oct 10, 2022
Convert All TXT Files To One File.

AllToOne Convert All TXT Files To One File. Hi ?? , I'm Alireza A Python Developer Boy ?? I’m currently working on my C# projects ?? I’m currently Lea

null 4 Jun 7, 2022
Two scripts help you to convert csv file to md file by template

Two scripts help you to convert csv file to md file by template. One help you generate multiple md files with different filenames from the first colume of csv file. Another can generate one md file with several blocks.

null 2 Oct 15, 2022
dotsend is a web application which helps you to upload your large files and share file via link

dotsend is a web application which helps you to upload your large files and share file via link

Devocoe 0 Dec 3, 2022
Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Python function to stream unzip all the files in a ZIP archive: without loading the entire ZIP file or any of its files into memory at once

Department for International Trade 206 Jan 2, 2023
Here is some Python code that allows you to read in SVG files and approximate their paths using a Fourier series.

Here is some Python code that allows you to read in SVG files and approximate their paths using a Fourier series. The Fourier series can be animated and visualized, the function can be output as a two dimensional vector for Desmos and there is a method to output the coefficients as LaTeX code.

Alexander 12 Jan 1, 2023
Provides a convenient way to append numpy arrays to a file.

Provides a convenient way to append numpy arrays to a file. The NpendWriter and NpendReader classes are used to write and read numpy arrays respective

null 3 May 14, 2022