Reputation: 241
I am working on a script to get information from the Skype database. I got the following code:
con = sqlite3.connect('C:\\Users\\joey\\AppData\\Roaming\\Skype\\jre93\\main.db')
But the skype ID (jre93) and the USER (joey) of the computer are always different. Is there a way python can recognize those path automatic with out user input?
Upvotes: 1
Views: 245
Reputation: 5315
Usually the folder with name of skype ID
contains the main.db
file!
So we can use this fact to get the skype ID.
One method to do so is to first check if there is any skype folder at that particular path. Then find the folder in the skype folder, that contains the main.db file. If a folder is found then the name of this folder is the skype ID.
I have created a small quick and dirty script for this work. (It can be further improved)
Code:
import getpass
import os
import sys
userName = getpass.getuser() #Get the username
path = "C:\\Users\\"+userName+"\\AppData\\Roaming\\Skype\\"
if (os.path.isdir(path)) == True: #Check if Skype folder exists
subdirectories = os.listdir(path)
for i in subdirectories:
if os.path.isdir(path+i) == True:
if os.path.exists(path+i+"\\main.db"):
print ("Skype Id is %s") %i
else:
print 'Skype folder does not exists'
I hope it was helpful.
Upvotes: 2