Intermediate Python tutorial in which we will create a folder organiser. This will put files into categories such as Audio, Video, Text, Executables, etc. and move them into their corresponding folders automatically.
The extensions code to copy and paste is at the bottom of the description.
If you have any questions or video requests, drop them in the comments below and I'll do my best to help
If you find this video helpful, please hit like and subscribe as it really helps my channel to grow :)
---------------------------- Contents ----------------------------
0:00 Demonstration
0:38 Coding Roadmap
2:48 get_all_files()
4:23 get_file_extension()
5:20 get_extension_category()
6:38 move_file()
8:06 delete_empty_directories
9:00 get_base_path()
14:18 Demonstration
Extensions Code:
extensions = {
"Audio": [
".aif",
".cda",
".mid",
".midi",
".mp3",
".mpa",
".ogg",
".wav",
".wma",
".wpl",
],
"Compressed Files": [
".7z",
".arj",
".deb",
".pkg",
".rar",
".rpm",
".tar.gz",
".z",
".zip",
],
"Disk Media": [
".bin",
".dmg",
".iso",
".toast",
],
"Data": [
".csv",
".dat",
".db",
".dbf",
".log",
".mdb",
".sav",
".sql",
".tar",
".xml",
],
"Email": [
".email",
".eml",
".emlx",
".msg",
".oft",
".vcf",
],
"Executables": [
".apk",
".bat",
".bin",
".cgi",
".pl",
".com",
".exe",
".gadget",
".jar",
".msi",
".py",
".wsf",
],
"Fonts": [
".fnt",
".fon",
".otf",
".ttf",
],
"Images": [
".ai",
".bmp",
".gif",
".ico",
".jpeg",
".jpg",
".png",
".ps",
".psd",
".svg",
".tif",
".tiff",
],
"Internet": [
".asp",
".aspx",
".cer",
".cfm",
".cgi",
".css",
".htm",
".html",
".js",
".jsp",
".part",
".php",
".py",
".rss",
".xhtml",
],
"Presentation": [
".key",
".odp",
".pps",
".ppt",
".pptx",
],
"Programming": [
".c",
".class",
".cpp",
".cs",
".h",
".java",
".pl",
".sh",
".swift",
".vb",
],
"Spreadsheet": [
".odsd",
".xls",
".xslm",
".xslx",
],
"System": [
".bak",
".cab",
".cfg",
".cpl",
".cur",
".dll",
".dmp",
".drv",
".icns",
".ico",
".ini",
".lnk",
".msi",
".sys",
".tmp",
],
"Video": [
".3g2",
".3gp",
".avi",
".flv",
".h264",
".m4v",
".mkv",
".mov",
".mp4",
".mpg",
".mpeg",
".rm",
".swf",
".vob",
".wmv",
],
Word Processor and Text Files
"Text": [
".doc",
".docx",
".pdf",
".rtf",
".tex",
".txt",
".wpd",
],
}