Created
September 13, 2020 11:54
-
-
Save pr0way/2cc733b4088574c769c3352cedb7e9d8 to your computer and use it in GitHub Desktop.
Simple script that make a file with list of files in directory and save them into file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os import path, scandir | |
print("Pass path to the directory: ") | |
mypath = path.join(input()) | |
filename = path.basename(mypath).lower() + '-tracklist.txt' | |
with scandir(mypath) as it: | |
list_of_files = [entry.name for entry in it if entry.is_file()] | |
list_of_files = sorted(list_of_files) | |
with open(filename, "w") as f: | |
f.writelines(line + '\n' for line in list_of_files) | |
## Example: | |
# Pass path to the directory: | |
# /home/johndoe/Music/CD1 | |
# We'll getting a sorted list with all our tracks in that directory in file named cd1-tracklist.txt. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment