• Home
  • Guides
    • All
    • Linux
    • Programming
    • Tools
    • WordPress
    Creating A Command-Line Python Radio Player

    Creating a Command-Line Python Radio Player

    Malware Detection With Maldet

    Malware Detection with Maldet

    Understanding And Implementing Clamav On Linux

    Understanding and Implementing ClamAV on Linux

    Simplifying Sms Alerts With Python And Smtp

    Simplifying SMS Alerts with Python and SMTP

    Automating Javascript Minification With Php

    Automating JavaScript Minification with PHP

    Secure Password Hashing

    Secure Password Hashing with PHP

    Synonym Word Replacer

    Create a Synonym Word Replacer with JavaScript

    Converting Images To Webp With Php

    Converting Images to WebP with PHP

    Verifying Artist Names In Mp3 Files Using The Last.fm Api With Python

    Verifying Artist Names in MP3 Files Using the Last.fm API with Python

  • Blog
    • All
    • Artificial Intelligence
    • Privacy
    • Python
    • Security
    Understanding Man-In-The-Middle Attacks

    Understanding Man-in-the-Middle Attacks

    Privacy-Focused Analytics

    Privacy-Focused Analytics: Balancing Insights and Integrity

    Safeguarding Your Facebook Account

    Safeguarding Your Facebook Account: Understanding the Differences Between Hacking and Cloning

    38 Essential Points To Harden Wordpress

    38 Essential Points to Harden WordPress

    10 Tips And Tricks To Secure Your Wordpress Website

    10 Tips and Tricks to Securing Your WordPress Website

    Ai And Coding: Will Ai Replace Coders?

    AI and Coding: Will Artificial Intelligence Replace Coders?

    Creating Strong Passwords

    Creating Strong Passwords: Factors, Best Practices, and Mistakes to Avoid

    Secure Your Online Life With Bitwarden

    Secure Your Online Life with Bitwarden

    Install Python 3 On Windows 10

    How to Install Python 3 on Windows 10

  • Services
    • WordPress Care Plans
    • WordPress Technical Support
  • Apps
    • Bible App
    • Blue AI Chatbot
    • FIGlet Generator
    • Password Generator
    • StegX
    • The Matrix
    • WeatherX
  • About
    • About JMooreWV
    • Live Cyber Attacks
  • Contact
No Result
View All Result
  • Home
  • Guides
    • All
    • Linux
    • Programming
    • Tools
    • WordPress
    Creating A Command-Line Python Radio Player

    Creating a Command-Line Python Radio Player

    Malware Detection With Maldet

    Malware Detection with Maldet

    Understanding And Implementing Clamav On Linux

    Understanding and Implementing ClamAV on Linux

    Simplifying Sms Alerts With Python And Smtp

    Simplifying SMS Alerts with Python and SMTP

    Automating Javascript Minification With Php

    Automating JavaScript Minification with PHP

    Secure Password Hashing

    Secure Password Hashing with PHP

    Synonym Word Replacer

    Create a Synonym Word Replacer with JavaScript

    Converting Images To Webp With Php

    Converting Images to WebP with PHP

    Verifying Artist Names In Mp3 Files Using The Last.fm Api With Python

    Verifying Artist Names in MP3 Files Using the Last.fm API with Python

  • Blog
    • All
    • Artificial Intelligence
    • Privacy
    • Python
    • Security
    Understanding Man-In-The-Middle Attacks

    Understanding Man-in-the-Middle Attacks

    Privacy-Focused Analytics

    Privacy-Focused Analytics: Balancing Insights and Integrity

    Safeguarding Your Facebook Account

    Safeguarding Your Facebook Account: Understanding the Differences Between Hacking and Cloning

    38 Essential Points To Harden Wordpress

    38 Essential Points to Harden WordPress

    10 Tips And Tricks To Secure Your Wordpress Website

    10 Tips and Tricks to Securing Your WordPress Website

    Ai And Coding: Will Ai Replace Coders?

    AI and Coding: Will Artificial Intelligence Replace Coders?

    Creating Strong Passwords

    Creating Strong Passwords: Factors, Best Practices, and Mistakes to Avoid

    Secure Your Online Life With Bitwarden

    Secure Your Online Life with Bitwarden

    Install Python 3 On Windows 10

    How to Install Python 3 on Windows 10

  • Services
    • WordPress Care Plans
    • WordPress Technical Support
  • Apps
    • Bible App
    • Blue AI Chatbot
    • FIGlet Generator
    • Password Generator
    • StegX
    • The Matrix
    • WeatherX
  • About
    • About JMooreWV
    • Live Cyber Attacks
  • Contact
No Result
View All Result
Home Guides Programming Python

Bulk Convert Windows URL Shortcuts to Linux Link Shortcuts

Jonathan Moore by Jonathan Moore
3 years ago
Reading Time: 2 mins read
A A
Bulk Convert Windows Url Shortcuts To Linux Link Shortcuts
FacebookTwitter

Are you migrating from the Windows Operating System to a Linux distribution and have shortcuts to your favorite websites stored on your Windows system?

Both Windows and Linux utilize a different file format for shortcuts. You cannot copy your Windows shortcuts to a Linux desktop and expect that they will work, because they won't. You will need to convert them into a format that Linux understands.

Windows URL shortcuts are stored in text files that end with either “.url” or “.website”, whereas Linux shortcuts are stored in text files that simply end with “.desktop”. The only common property within both of the Windows and Linux shortcuts is the URL property.

Luckily, Python can handle this conversion for us. The Python script below will iterate through a given directory and convert all of your Windows shortcuts into Linux-compatible shortcuts.

#!/usr/bin/python3

import os


def convert(directory):
    # Add all files from the directory into a list
    files = os.listdir(directory)
    # Iterate through the directory list
    for file in files:
        # Look for files ending in ".url" or ".website"
        if file.endswith(('.url', '.website')):
            # Set a file name without the file extension
            filename = os.path.splitext(file)[0]
            # Create new filename for Linux shortcut
            new_filename = os.path.join(directory, filename+".desktop")
            # Open and Read the file into memory
            with open(os.path.join(directory, file), "r") as f:
                # Loop through each line of the file
                for line in f:
                    # Strip line breaks from the end of each line
                    line = line.rstrip()
                    # Find the line that starts with "url="
                    if "url=" in line.lower():
                        # Create new Linux shortcut
                        with open(new_filename, "w") as nf:
                            nf.write("[Desktop Entry]\n")
                            nf.write("Name=" + filename + "\n")
                            nf.write("Type=Link\n")
                            nf.write("Icon=text-html\n")
                            nf.write(line)


if __name__ == "__main__":
    # Pass the Directory to the convert function
    convert("/home/user/Desktop/Windows Shortcuts")

 

Tags: ProgrammingPython
ShareTweetSharePinShareShareScan
ADVERTISEMENT
Jonathan Moore

Jonathan Moore

Senior Software Engineer and Cybersecurity Specialist with over 3 decades of experience in developing web, desktop, and server applications for Linux and Windows-based operating systems. Worked on numerous projects, including automation, artificial intelligence, data analysis, application programming interfaces, intrusion detection systems, streaming audio servers, WordPress plugins, and much more.

Related Articles

Creating A Command-Line Python Radio Player

Creating a Command-Line Python Radio Player

In this tutorial, I'll walk you through the process of creating a command-line radio player using Python and ffplay, a...

Simplifying Sms Alerts With Python And Smtp

Simplifying SMS Alerts with Python and SMTP

Whether it's for emergency notifications or simple reminders, sending SMS alerts is a powerful way to get your message across....

Synonym Word Replacer

Create a Synonym Word Replacer with JavaScript

Writing compelling and engaging content often requires finding the perfect words to convey our thoughts. However, occasionally we find ourselves...

Next Post
The Ultimate Spy Game

The Ultimate Spy Game

Recommended Services

Subscribe for Updates

Would you like to be notified when a new article is published? You can unsubscribe at any time.

Subscribe

Latest Articles

Understanding Man-in-the-Middle Attacks

Understanding Man-In-The-Middle Attacks

Man-in-the-middle (MitM) attacks have earned a notorious reputation as one of the most insidious and potentially devastating cybersecurity threats today....

Read more

Creating a Command-Line Python Radio Player

Creating A Command-Line Python Radio Player

In this tutorial, I'll walk you through the process of creating a command-line radio player using Python and ffplay, a...

Read more

Malware Detection with Maldet

Malware Detection With Maldet

Malware, short for malicious software, is a ubiquitous threat to all computer systems. It's the covert intruder that sneaks into...

Read more

Understanding and Implementing ClamAV on Linux

Understanding And Implementing Clamav On Linux

The perpetual arms race between threat actors and defenders often hinges on the tools each employs. For Linux users, one...

Read more
473 Spam Attacks blocked with CleanTalk
  • Privacy Policy
  • Terms of Service

© 2023 JMooreWV. All rights reserved.

No Result
View All Result
  • Home
  • Guides
    • Linux
    • Programming
      • JavaScript
      • PHP
      • Python
    • Tools
    • WordPress
  • Blog
    • Artificial Intelligence
    • Python
    • Privacy
    • Security
  • Services
    • Privacy Focused Web Analytics
    • WordPress Care Plans
    • WordPress Technical Support
  • Apps
    • Bible App
    • Blue AI Chatbot
    • FIGlet Generator
    • Password Generator
    • StegX
    • The Matrix
    • WeatherX
  • About
    • About JMooreWV
    • Live Cyber Attacks
  • Contact