[Python] Convert the content of a folder to the tasks

A place to post your ideas and solutions for how best to make use of the software

Moderators: abstr, Niko

Post Reply
Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

[Python] Convert the content of a folder to the tasks

Post by Niko » Tue Nov 05, 2019 12:07 pm

This trick could be helpful if you have a lot of files in a folder on your PC which you need to examine (it could be books, tutorials etc.) and you want to add these files to ToDoList as the tasks.
1. You need to install Python IDE. I use thonny.org
2. Copy and edit the code:

Code: Select all

import os

l = os.listdir(r"C:\Aristotle") # the path to a folder with files
for x in l:
    if ".zip" in x: # exclude files with .zip extension
        continue
    print ("Nicom.eth.: "+x) # Add the prefix to the name of a task
Python.gif
Python.gif (35.25 KiB) Viewed 3790 times
3. Press F5 to run the code
4. Copy the values from the Shell
5. Open ToDoList
Python2.gif
Python2.gif (211.69 KiB) Viewed 3790 times
6.Press Ctrl+I
7. Paste text

JoHeDe
Posts: 29
Joined: Sat Sep 28, 2019 9:25 am

Re: [Python] Convert the content of a folder to the tasks

Post by JoHeDe » Tue Nov 05, 2019 6:08 pm

that's nice - thx for sharing, Niko

Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

Re: [Python] Convert the content of a folder to the tasks

Post by Niko » Wed Nov 06, 2019 7:43 am

You are welcome!
Next time I will post some useful tricks related to the metadata of files and how it can be used in ToDoList.

Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

Re: [Python] Convert the content of a folder to the tasks

Post by Niko » Mon Nov 18, 2019 8:33 pm

This method could be used to convert chapters of a book into tasks in ToDoList:

Code: Select all

ChapName = str("The name of the book. Chapter №")
for x in range (1,101): # from 1 to 100
    x = str(x)
    print (ChapName+x)
book.gif
book.gif (120.11 KiB) Viewed 3720 times

user0x
Posts: 7
Joined: Sat Aug 03, 2019 3:01 am

Re: [Python] Convert the content of a folder to the tasks

Post by user0x » Thu Dec 19, 2019 6:11 pm

It will be great if the links are live i.e. files and folders are mapped into the Tasklist dynamically. That way changes in the Tasklist or the native OS explorer are in sync.

User avatar
abstr
Site Admin
Posts: 369
Joined: Sun Jul 28, 2019 12:22 pm

Re: [Python] Convert the content of a folder to the tasks

Post by abstr » Thu Jan 09, 2020 4:45 am

You would have to write a plugin for that...

Niko
Posts: 239
Joined: Wed Sep 18, 2019 6:48 am

Re: [Python] Convert the content of a folder to the tasks

Post by Niko » Thu Jan 09, 2020 7:59 pm

user0x wrote:
Thu Dec 19, 2019 6:11 pm
It will be great if the links are live i.e. files and folders are mapped into the Tasklist dynamically. That way changes in the Tasklist or the native OS explorer are in sync.
I can't imagine how that would work with tasks. Let's say, I have 100 folder in each folder there are at least 10 pdf files. It would just duplicate the content of the folders. Maybe you could provide some examples how to use that feature in practice.

JonR
Posts: 35
Joined: Sun Aug 04, 2019 2:42 pm

Re: [Python] Convert the content of a folder to the tasks

Post by JonR » Mon Feb 10, 2020 10:34 pm

I was browsing Tips & Tricks so thought I would add my (non-coder) experience of using Xplorer2 which has 'copy names/columns' feature. This allows you to select a set of items in a folder and copy the filename text (etc) rather than the files themselves.

(Xplorer2 is awesome, like TDL!).

Also being old skool I would maybe use a DOS run cmd such as 'dir name.ext >list.txt'. This would need more work and my memory is hazy but researching this took me to a random web resource which might be of interest - https://www.hanselman.com/blog/Forgotte ... tures.aspx

Post Reply