GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Python/Organise.py at master · CHAOYUHONG/Python

Expand file tree

/

Organise.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
57 lines (48 loc) · 2.04 KB
/

Organise.py

Copy path

File metadata and controls

57 lines (48 loc) · 2.04 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from __future__ import print_function
import os
import sys
import shutil
EXT_VIDEO_LIST = ['FLV', 'WMV', 'MOV', 'MP4', 'MPEG', '3GP', 'MKV','AVI']
EXT_IMAGE_LIST = ['JPG', 'JPEG', 'GIF', 'PNG', 'SVG']
EXT_DOCUMENT_LIST = ['DOC', 'DOCX', 'PPT', 'PPTX', 'PAGES', 'PDF', 'ODT', 'ODP', 'XLSX', 'XLS', 'ODS', 'TXT', 'IN', 'OUT', 'MD']
EXT_MUSIC_LIST = ['MP3', 'WAV', 'WMA', 'MKA', 'AAC', 'MID', 'RA', 'RAM', 'RM', 'OGG']
EXT_CODE_LIST = ['CPP', 'RB', 'PY', 'HTML', 'CSS', 'JS']
EXT_EXECUTABLE_LIST = ['LNK','DEB', 'EXE', 'SH', 'BUNDLE']
EXT_COMPRESSED_LIST = ['RAR', 'JAR', 'ZIP', 'TAR', 'MAR', 'ISO', 'LZ', '7ZIP', 'TGZ', 'GZ', 'BZ2']
# Taking the location of the Folder to Arrange
try:
destLocation = str(sys.argv[1])
except IndexError:
destLocation = str(input('Enter the Path of directory: '))
# When we make a folder that already exist then WindowsError happen
# Changing directory may give WindowsError
def ChangeDirectory(dir):
try:
os.chdir(dir)
except WindowsError:
print ('Error! Cannot change the Directory')
print ('Enter a valid directory!')
ChangeDirectory(str(input('Enter the Path of directory: ')))
ChangeDirectory(destLocation)
def Organize(dirs, name):
try:
os.mkdir(name)
print ('{} Folder Created'.format(name))
except WindowsError:
print ('{} Folder Exist'.format(name))
src = '{}\\{}'.format(destLocation, dirs)
dest = '{}\{}'.format(destLocation, name)
os.chdir(dest)
shutil.move(src, '{}\\{}'.format(dest, dirs))
print(os.getcwd())
os.chdir(destLocation)
TYPES_LIST = ['Video', 'Images', 'Documents', 'Music', 'Codes', 'Executables', 'Compressed']
for dirs in os.listdir(os.getcwd()):
if 1:
for name, extensions_list in zip(TYPES_LIST, [EXT_VIDEO_LIST, EXT_IMAGE_LIST, EXT_DOCUMENT_LIST, EXT_MUSIC_LIST, EXT_CODE_LIST, EXT_EXECUTABLE_LIST, EXT_COMPRESSED_LIST]):
if dirs.split('.')[-1].upper() in extensions_list:
Organize(dirs, name)
else:
if dirs not in TYPES_LIST:
Organize(dirs, 'Folders')
print ('Done Arranging Files and Folder in your specified directory')
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.