GithubHelp home page GithubHelp logo

varun325 / python_script_to_manage_your_folders_automatically Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 33 KB

Python script which can run in the background to unclutter your folders.

Python 100.00%

python_script_to_manage_your_folders_automatically's Introduction

Python Script to manage your folders automatically

This Script can run in back ground and move files to different folders based upon file types

In this example we have managed the download folder

Custom editing steps:

  •    #change
       folder = "/Downloads"
       #to
       folder = "/Your/folder"
  • You can add extra conditions or modify the existing ones and change the folder names if you know your way around python for. example:
    •   folder ="/Downloads"
        #folder ="/Your/folder"
        home = Path.home()
        
        #Replace "/Books" with the destination folder
        #You can also replace books with a different variable name
        if not os.path.exists(str(home)+folder+"/Books"):
            os.makedirs(str(home)+folder+"/Books")
      
        book = str(home)+folder+"/Books"
        #instead of ".epub", you can mention other formats as well
        files = [i for i in os.listdir(src) if path.isfile(path.join(src, i))]
        for f in files:
            if f.endswith(".epub") or f.endswith(".EPUB"):
                shutil.move(path.join(src, f), path.join(book,f))

Making the script run in background(LINUX {UBUNTU})

we are using crontab to run script in background

  • copy the contents to /bin
    •   user@machine:~$ sudo cp -i /your/file/path/watch.py /bin 
  • open crontab, select 1 to 4 if you haven't assigned any
    •   user@machine:~$ sudo crontab -e
  • Add the given line to your crontab
    •   @reboot sudo -u username python3 /bin/watch.py
  • Reboot the system
    •   user@machine:~$ reboot

Making the script run in background(Windows)

we are using pythonw.exe to run script in background

  • copy the watchWin.pyw to
    •    C:\Users\current_user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\
  • run %appdata if you can't find AppData in User directory
  • add file to the windows registry folder by running the appRegistry.py script
    •    C:\Your\File\Path> python3 appRegistry.py
  • on startup windows will execute (Windows does this automatically, it's here just for explanation)
    •    C:\Users\current_user\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup> pythonw.exe watchWin.pyw
  • Reboot the system

Happy Scripting ๐Ÿ’ป โค๏ธ

python_script_to_manage_your_folders_automatically's People

Contributors

varun325 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.