-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patharchiver.py
More file actions
39 lines (30 loc) · 745 Bytes
/
archiver.py
File metadata and controls
39 lines (30 loc) · 745 Bytes
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
#/usr/bin/env python3
# 04 October 2018, St. Paul, MN
# Peter L. Morrell - tired of manually creating tarred and bzipped archives
# Needed for arguments below
import os
import sys
import tarfile
Usage = """
Usage:
python archiver.py directory_name
"""
if len(sys.argv) < 1:
print(Usage)
exit(1)
#####
# Defining arguments
#####
# A description of the program
DESCR = """A Python tool for archiving directories."""
# Create a new argument parser
try:
directory_name = sys.argv[1]
print(directory_name)
except:
print('Please pass directory_name')
with tarfile.open( directory_name + ".tar.bz2", "w:bz2" ) as tar:
name = os.listdir( directory_name )
#print(name)
tar.add(name)
tar.close()