added import function
This commit is contained in:
parent
291fffe057
commit
35a58d4952
|
@ -6,6 +6,7 @@ All information is stored inside of an SQLite-database. Two separate tables are
|
||||||
* add - Add a file and entry to the index
|
* add - Add a file and entry to the index
|
||||||
* check - check if all files saved in the index exist and aren't faulty
|
* check - check if all files saved in the index exist and aren't faulty
|
||||||
* delete - delete a file and remove the entry
|
* delete - delete a file and remove the entry
|
||||||
|
* import - lets you add every file to the index in a chosen directory
|
||||||
* meta - a command to change aliases of categorties and tags
|
* meta - a command to change aliases of categorties and tags
|
||||||
* open - open one or more files from the index in the default application (only Linux and Windows)
|
* open - open one or more files from the index in the default application (only Linux and Windows)
|
||||||
* show - search through the index and show the matches
|
* show - search through the index and show the matches
|
||||||
|
|
31
image-index
31
image-index
|
@ -538,13 +538,17 @@ def add(args):
|
||||||
eingabe="default"
|
eingabe="default"
|
||||||
args.append(eingabe)
|
args.append(eingabe)
|
||||||
if i in ["Filepath"]:
|
if i in ["Filepath"]:
|
||||||
|
filehash=tb.get_hash(args[n])
|
||||||
|
if filehash in str(tb.get_col("HASH")):
|
||||||
|
print("This file already exists!")
|
||||||
|
return False
|
||||||
if not args[n]:
|
if not args[n]:
|
||||||
print("{} must not be empty!".format(i))
|
print("{} must not be empty!".format(i))
|
||||||
return 1
|
return False
|
||||||
else:
|
else:
|
||||||
if not Path(args[n]).is_file():
|
if not Path(args[n]).is_file():
|
||||||
print(" The file '{}' doesn't exist or is not a file!".format(args[n]))
|
print(" The file '{}' doesn't exist or is not a file!".format(args[n]))
|
||||||
return 1
|
return False
|
||||||
n+=1
|
n+=1
|
||||||
success=tb.add_index(args[0],args[1],args[2],args[3],args[4],args[5])
|
success=tb.add_index(args[0],args[1],args[2],args[3],args[4],args[5])
|
||||||
if success:
|
if success:
|
||||||
|
@ -633,6 +637,9 @@ def help(args):
|
||||||
print("delete:\tdeletes a file and entry based on a search query;\n\tInstant: image-index delete <words/filters>")
|
print("delete:\tdeletes a file and entry based on a search query;\n\tInstant: image-index delete <words/filters>")
|
||||||
print("\tPrompt: image-index delete")
|
print("\tPrompt: image-index delete")
|
||||||
print("EXAMPLE:\nimage-index delete -t Example -g Tag Example -a .mp4 add\n")
|
print("EXAMPLE:\nimage-index delete -t Example -g Tag Example -a .mp4 add\n")
|
||||||
|
elif re.match('[iI].*',arg):
|
||||||
|
print("\timport:\tshows an add prompt for every file in a directory;\n\t\tSyntax: image-index import <directory path>")
|
||||||
|
print("EXAMPLE:\nimage-index import ~/Pictures/Vacation\n")
|
||||||
elif re.match('[oO].*',arg):
|
elif re.match('[oO].*',arg):
|
||||||
print("open:\topens a file based on a search query in the standard app;\n\tInstant: image-index open <words/filters>")
|
print("open:\topens a file based on a search query in the standard app;\n\tInstant: image-index open <words/filters>")
|
||||||
print("\tPrompt: image-index open")
|
print("\tPrompt: image-index open")
|
||||||
|
@ -659,10 +666,24 @@ def help(args):
|
||||||
print("\tadd:\tadds a new entry;\n\t\tSyntax: image-index add <filepath> <category> <title> <source> <tags> <content>")
|
print("\tadd:\tadds a new entry;\n\t\tSyntax: image-index add <filepath> <category> <title> <source> <tags> <content>")
|
||||||
print("\tcheck:\tchecks the existence and correctness of all files in the index;\n\t\tSyntax: image-index check [options]")
|
print("\tcheck:\tchecks the existence and correctness of all files in the index;\n\t\tSyntax: image-index check [options]")
|
||||||
print("\tdelete:\tdeletes a file and entry based on a search query;\n\t\tSyntax: image-index delete <words/filters>")
|
print("\tdelete:\tdeletes a file and entry based on a search query;\n\t\tSyntax: image-index delete <words/filters>")
|
||||||
|
print("\timport:\tshows an add prompt for every file in a directory;\n\t\tSyntax: image-index import <directory path>")
|
||||||
print("\topen:\topens a file based on a search query in the standard app;\n\t\tSyntax: image-index open <words/filters>")
|
print("\topen:\topens a file based on a search query in the standard app;\n\t\tSyntax: image-index open <words/filters>")
|
||||||
print("\tshow:\tsearches through the index and shows the matches;\n\t\tSyntax: image-index show <words/filters>")
|
print("\tshow:\tsearches through the index and shows the matches;\n\t\tSyntax: image-index show <words/filters>")
|
||||||
print("\tupdate:\tchanges specific column based on a search query;\n\t\tSyntax: image-index update <column> <updated_value> <words/filters>")
|
print("\tupdate:\tchanges specific column based on a search query;\n\t\tSyntax: image-index update <column> <updated_value> <words/filters>")
|
||||||
|
|
||||||
|
def imports(args):
|
||||||
|
for arg in args:
|
||||||
|
if os.path.exists(arg):
|
||||||
|
if not Path(arg).is_file():
|
||||||
|
for sfile in os.listdir(arg):
|
||||||
|
if Path(arg,sfile).is_file():
|
||||||
|
#print("{}{}".format(arg,sfile))
|
||||||
|
add(["{}{}".format(arg,sfile)])
|
||||||
|
else:
|
||||||
|
print("Path '{}' is a file!".format(arg))
|
||||||
|
else:
|
||||||
|
print("Path '{}' doesn't exist!".format(arg))
|
||||||
|
|
||||||
def meta(args):
|
def meta(args):
|
||||||
if len(args) == 0 or re.match('[hH].*',args[0]):
|
if len(args) == 0 or re.match('[hH].*',args[0]):
|
||||||
meta_help()
|
meta_help()
|
||||||
|
@ -737,7 +758,7 @@ def meta_help():
|
||||||
print('\t\tExamples: image-index meta update tags Example "New alias"')
|
print('\t\tExamples: image-index meta update tags Example "New alias"')
|
||||||
print('\t\t\t image-index meta update category "A Category" "Example Category"\n')
|
print('\t\t\t image-index meta update category "A Category" "Example Category"\n')
|
||||||
|
|
||||||
def sopen(args):
|
def opens(args):
|
||||||
plat=sys.platform
|
plat=sys.platform
|
||||||
selection=search(args,True)
|
selection=search(args,True)
|
||||||
for sel in selection:
|
for sel in selection:
|
||||||
|
@ -850,8 +871,10 @@ def main():
|
||||||
check(args)
|
check(args)
|
||||||
elif re.match('[dD].*',command):
|
elif re.match('[dD].*',command):
|
||||||
delete(args)
|
delete(args)
|
||||||
|
elif re.match('[iI].*',command):
|
||||||
|
imports(args)
|
||||||
elif re.match('[oO].*',command):
|
elif re.match('[oO].*',command):
|
||||||
sopen(args)
|
opens(args)
|
||||||
elif re.match('[sS].*',command):
|
elif re.match('[sS].*',command):
|
||||||
show(args)
|
show(args)
|
||||||
elif re.match('[uU].*',command):
|
elif re.match('[uU].*',command):
|
||||||
|
|
Loading…
Reference in a new issue