Skip to content

Commit

Permalink
Implement #25
Browse files Browse the repository at this point in the history
Copying media folder to the output directory will be the default starting from this commit.
  • Loading branch information
KnugiHK committed Jan 31, 2023
1 parent 14b1cb7 commit 60575c7
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions Whatsapp_Chat_Exporter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ def main():
default=False,
action='store_true',
help="Show the HEX key used to decrypt the database")
parser.add_option(
"-c",
"--copy-media",
dest="copy_media",
default=True,
action='store_true',
help="Copy media directory to output directory, otherwise move the media directory to output directory")
(options, args) = parser.parse_args()

if options.android and options.iphone:
Expand Down Expand Up @@ -193,13 +200,18 @@ def main():
)
exit(2)

if os.path.isdir(options.media) and \
not os.path.isdir(f"{options.output}/{options.media}"):
try:
shutil.move(options.media, f"{options.output}/")
except PermissionError:
print("Cannot remove original WhatsApp directory. "
"Perhaps the directory is opened?")
if os.path.isdir(options.media):
if os.path.isdir(f"{options.output}/{options.media}"):
print("Media directory already exists in output directory. Skipping...")
else:
if options.copy_media:
shutil.copytree(options.media, f"{options.output}/WhatsApp")
else:
try:
shutil.move(options.media, f"{options.output}/")
except PermissionError:
print("Cannot remove original WhatsApp directory. "
"Perhaps the directory is opened?")

if options.json:
with open("result.json", "w") as f:
Expand Down

0 comments on commit 60575c7

Please sign in to comment.