check for filename dupes on drive
This commit is contained in:
parent
1e31416ac8
commit
d11df4e7ce
1 changed files with 10 additions and 1 deletions
|
@ -7,6 +7,7 @@ if sys.version_info < (3, 3):
|
||||||
sys.stderr.write("Sorry, requires at least Python 3.3\n")
|
sys.stderr.write("Sorry, requires at least Python 3.3\n")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
import collections
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -25,7 +26,15 @@ gauth.CommandLineAuth()
|
||||||
drive = GoogleDrive(gauth)
|
drive = GoogleDrive(gauth)
|
||||||
|
|
||||||
file_list = drive.ListFile({'q': "'{}' in parents and trashed=false".format(FOLDER)}).GetList()
|
file_list = drive.ListFile({'q': "'{}' in parents and trashed=false".format(FOLDER)}).GetList()
|
||||||
# XXX Check for filename dupes
|
|
||||||
|
file_names = [f['title'] for f in file_list]
|
||||||
|
file_names_dupes = [f for f, count in collections.Counter(file_names).items() if count > 1]
|
||||||
|
if len(file_names_dupes) > 0:
|
||||||
|
print('Duplicate filenames on Drive!')
|
||||||
|
for fn in sorted(file_names_dupes):
|
||||||
|
print(fn)
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
for file1 in file_list:
|
for file1 in file_list:
|
||||||
if file1['mimeType'] == 'application/vnd.google-apps.folder':
|
if file1['mimeType'] == 'application/vnd.google-apps.folder':
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue