From 5a5b98cccbffe75b6e418e23572c704e8f3341cb Mon Sep 17 00:00:00 2001 From: Ross Scroggs Date: Fri, 17 May 2024 07:42:32 -0700 Subject: [PATCH] Added option `folderpathonly []` to commands that display paths --- docs/Authorization.md | 3 + docs/GamUpdates.md | 12 ++++ docs/How-to-Upgrade-from-Standard-GAM.md | 4 +- docs/Other-Resources.md | 17 +++--- docs/Users-Drive-Files-Display.md | 32 +++++++--- docs/Version-and-Help.md | 12 ++-- src/GamCommands.txt | 15 ++--- src/GamUpdate.txt | 12 ++++ src/gam/__init__.py | 77 +++++++++++++++--------- 9 files changed, 123 insertions(+), 61 deletions(-) diff --git a/docs/Authorization.md b/docs/Authorization.md index 2a30effd..0e3e4d31 100644 --- a/docs/Authorization.md +++ b/docs/Authorization.md @@ -342,6 +342,9 @@ Use an existing project to create and download two files: `client_secrets.json` ### Basic Use an existing uninitialized/uncredentialed project and configure it to be a GAM project; this typically used when the GCP administrators have created a basic project because project creation is not available for most users. + +See Jay's notes about how to do this: https://github.com/GAM-team/GAM/wiki/GAM-with--minimal-GCP-rights + ``` gam use project [] [project ] ``` diff --git a/docs/GamUpdates.md b/docs/GamUpdates.md index 28e09cfd..9c3e3c91 100644 --- a/docs/GamUpdates.md +++ b/docs/GamUpdates.md @@ -10,6 +10,18 @@ Add the `-s` option to the end of the above commands to suppress creating the `g See [Downloads](https://github.com/taers232c/GAMADV-XTD3/wiki/Downloads) for Windows or other options, including manual installation +### 6.76.03 + +Added option `folderpathonly []` to the following commands that causes GAM +to display only the folder names when displaying the path to a file. This folder only path +an be used in `gam create drivefolderpath` to recreate the folder hierarchy. +``` +gam info drivefile ... filepath|fullpath +gam show fileinfo ... filepath|fullpath +gam print|show filepath +gam print filelist ... filepath|fullpath +``` + ### 6.76.02 Updated `gam update group` to handle the following error: diff --git a/docs/How-to-Upgrade-from-Standard-GAM.md b/docs/How-to-Upgrade-from-Standard-GAM.md index 0e47bf46..0a5b4b86 100644 --- a/docs/How-to-Upgrade-from-Standard-GAM.md +++ b/docs/How-to-Upgrade-from-Standard-GAM.md @@ -335,7 +335,7 @@ writes the credentials into the file oauth2.txt. admin@server:/Users/admin/bin/gamadv-xtd3$ rm -f /Users/admin/GAMConfig/oauth2.txt admin@server:/Users/admin/bin/gamadv-xtd3$ ./gam version WARNING: Config File: /Users/admin/GAMConfig/gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: /Users/admin/GAMConfig/oauth2.txt, Not Found -GAMADV-XTD3 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 @@ -1009,7 +1009,7 @@ writes the credentials into the file oauth2.txt. C:\GAMADV-XTD3>del C:\GAMConfig\oauth2.txt C:\GAMADV-XTD3>gam version WARNING: Config File: C:\GAMConfig\gam.cfg, Section: DEFAULT, Item: oauth2_txt, Value: C:\GAMConfig\oauth2.txt, Not Found -GAMADV-XTD3 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final Windows-10-10.0.17134 AMD64 diff --git a/docs/Other-Resources.md b/docs/Other-Resources.md index 7568188a..3d771c66 100644 --- a/docs/Other-Resources.md +++ b/docs/Other-Resources.md @@ -4,14 +4,15 @@ The following are links to contributions of others in support of GAMADV-XTD3. Thank you. -* Gabriel Clifton - https://docs.google.com/document/d/1p32QOBTr89GaG7RfCafSbFuhlUQ9r3qBM_666E0xvQM/edit -* Steve Larsen - https://docs.google.com/spreadsheets/d/1MzzA-u-cmoQcJnQOovCnZcEKMjvOyFhfkdFdf10X_GI/edit -* Iain Macleod - https://docs.google.com/document/d/1QxWAPdhROcx70OXLpSD9Trh3vs-nJKSMiaMZCTwOOTg/edit?pli=1#heading=h.2a2azzpy36k0 -* Kevin Melillo - https://github.com/KevinMelilloIEEE/gam-script -* James Seymour - https://sites.google.com/jis.edu.bn/gam-commands/home * Amado Tejada - https://github.com/amadotejada/GAMpass -* Workspace Admins YouTube Channel - https://youtube.com/@googleworkspaceadmins +* Brecht Sannen - https://gcloud.devoteam.com/blog/what-is-google-apps-manager-gam/ +* Gabriel Clifton - https://docs.google.com/document/d/1p32QOBTr89GaG7RfCafSbFuhlUQ9r3qBM_666E0xvQM/edit * Goldy Arora - https://www.goldyarora.com/license-notifier/ -* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Tutorials https://www.youtube.com/watch?v=g9LDeyXQNLI&list=PL_dLiK09pJVhKJxZHNk9CHK0q5hkZ856w +* Iain Macleod - https://docs.google.com/document/d/1QxWAPdhROcx70OXLpSD9Trh3vs-nJKSMiaMZCTwOOTg/edit?pli=1#heading=h.2a2azzpy36k0 +* James Seymour - https://sites.google.com/jis.edu.bn/gam-commands/home +* Kevin Melillo - https://github.com/KevinMelilloIEEE/gam-script * Paul Ogier (Taming.Tech) - GAMADV-XTD3 Course on Udemy https://taming.tech/GAMCourse -* Paul Ogier (Taming.Tech) - https://taming.tech/taming-gam-a-practical-guide-to-gam-and-gamadv-xtd3/ \ No newline at end of file +* Paul Ogier (Taming.Tech) - GAMADV-XTD3 Tutorials https://www.youtube.com/watch?v=g9LDeyXQNLI&list=PL_dLiK09pJVhKJxZHNk9CHK0q5hkZ856w +* Paul Ogier (Taming.Tech) - https://taming.tech/taming-gam-a-practical-guide-to-gam-and-gamadv-xtd3/ +* Steve Larsen - https://docs.google.com/spreadsheets/d/1MzzA-u-cmoQcJnQOovCnZcEKMjvOyFhfkdFdf10X_GI/edit +* Workspace Admins YouTube Channel - https://youtube.com/@googleworkspaceadmins diff --git a/docs/Users-Drive-Files-Display.md b/docs/Users-Drive-Files-Display.md index a58595f0..48386366 100644 --- a/docs/Users-Drive-Files-Display.md +++ b/docs/Users-Drive-Files-Display.md @@ -396,7 +396,7 @@ Display file details in indented keyword: value format. The two forms are equiva ``` gam show fileinfo [returnidonly] - [filepath|fullpath] [pathdelimiter ] + [filepath|fullpath] [folderpathonly []] [pathdelimiter ] [allfields|*|(fields )] (orderby [ascending|descending])* [showdrivename] [showshareddrivepermissions] @@ -406,7 +406,7 @@ gam show fileinfo [formatjson] gam info drivefile [returnidonly] - [filepath|fullpath] [pathdelimiter ] + [filepath|fullpath] [folderpathonly []] [pathdelimiter ] [allfields|*|(fields )] (orderby [ascending|descending])* [showdrivename] [showshareddrivepermissions] @@ -421,6 +421,10 @@ Use `filepath` to display the path(s) to the files in ``. Use `fullpath` to add additional path information indicating that a file is an Orphan or Shared with me. +By default, the path to a file includes the file name as the last element of the path. +Use `folderpathonly` to display only the folder names when displaying the path to a file. This folder only path +an be used in `gam create drivefolderpath` to recreate the folder hierarchy. + By default, file path components are separated by `/`; use `pathdelimiter ` to use `` as the separator. When `allfields` is specified (or no fields are specified), use `showdrivename` to display Shared(Team) Drive names. @@ -479,16 +483,21 @@ By default, Gam displays the information as an indented list of keys and values. gam show filepath [returnpathonly] (orderby [ascending|descending])* - [stripcrsfromname] [fullpath] [pathdelimiter ] + [stripcrsfromname] + [folderpathonly []] [fullpath] [pathdelimiter ] gam print filepath [todrive *] (orderby [ascending|descending])* - [stripcrsfromname] [fullpath] [pathdelimiter ] - [oneitemperrow] + [stripcrsfromname] [oneitemperrow] + [fullpath] [folderpathonly []] [pathdelimiter ] ``` Use `returnpathonly` to display just the file path of the files in ``. Use `fullpath` to add additional path information indicating that a file is an Orphan or Shared with me. +By default, the path to a file includes the file name as the last element of the path. +Use `folderpathonly` to display only the folder names when displaying the path to a file. This folder only path +an be used in `gam create drivefolderpath` to recreate the folder hierarchy. + By default, file path components are separated by `/`; use `pathdelimiter ` to use `` as the separator. The `stripcrsfromname` option strips nulls, carriage returns and linefeeds from drive file names. @@ -1009,8 +1018,9 @@ gam print|show filelist [todrive *] [excludetrashed] [maxfiles ] [nodataheaders ] [countsonly [summary none|only|plus] [summaryuser ] - [showsource] [showsize] [showmimetypesize]] [countsrowfilter] - [filepath|fullpath [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] + [showsource] [showsize] [showmimetypesize]] + [countsrowfilter] + [filepath|fullpath [folderpathonly []] [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] [allfields|*|(fields )] [showdrivename] [showshareddrivepermissions] [(showlabels details|ids)|(includelabels )] @@ -1117,13 +1127,13 @@ By default, when a folder is selected, only its contents are displayed. ## Choose what fields to display If no query or select is performed, use these options to get file path information: * `filepath|fullpath` - For files and folders, display the full path(s) to them starting at the root (My Drive) -* `addcsvdata ` - Add additional columns of data from the command line to the output * `addpathstojson` - When this option and `formatjson` are specified, the path information will be included in the JSON data rather than as additional columns +* `addcsvdata ` - Add additional columns of data from the command line to the output When used with `filepath` or `fullpath`, `showdepth` will display a `depth` column. Files/folders directly in `My Drive` are at depth 0, the depth increases by 1 -for each containing folder. For files with multiple parents, the maximum depth is displayed. +for each containing folder. If a query or select is performed, use these options to get file path information: * `filepath` - For files, no path information is shown; for folders, the paths of all of its children are shown starting at the selected folder @@ -1131,6 +1141,10 @@ If a query or select is performed, use these options to get file path informatio * `addpathstojson` - When this option and `formatjson` are specified, the path information will be included in the JSON data rather than as additional columns +By default, the path to a file includes the file name as the last element of the path. +Use `folderpathonly` to display only the folder names when displaying the path to a file. This folder only path +an be used in `gam create drivefolderpath` to recreate the folder hierarchy. + By default, file path components are separated by `/`; use `pathdelimiter ` to use `` as the separator. By default, only the fields `id` and `webViewLink` are displayed. diff --git a/docs/Version-and-Help.md b/docs/Version-and-Help.md index bc83d795..ae57dc01 100644 --- a/docs/Version-and-Help.md +++ b/docs/Version-and-Help.md @@ -3,7 +3,7 @@ Print the current version of Gam with details ``` gam version -GAMADV-XTD3 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 @@ -15,7 +15,7 @@ Time: 2023-06-02T21:10:00-07:00 Print the current version of Gam with details and time offset information ``` gam version timeoffset -GAMADV-XTD3 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 @@ -27,7 +27,7 @@ Your system time differs from www.googleapis.com by less than 1 second Print the current version of Gam with extended details and SSL information ``` gam version extended -GAMADV-XTD3 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource +GAMADV-XTD3 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 - pythonsource Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 @@ -64,7 +64,7 @@ MacOS High Sierra 10.13.6 x86_64 Path: /Users/Admin/bin/gamadv-xtd3 Version Check: Current: 5.35.08 - Latest: 6.76.02 + Latest: 6.76.03 echo $? 1 ``` @@ -72,7 +72,7 @@ echo $? Print the current version number without details ``` gam version simple -6.76.02 +6.76.03 ``` In Linux/MacOS you can do: ``` @@ -82,7 +82,7 @@ echo $VER Print the current version of Gam and address of this Wiki ``` gam help -GAM 6.76.02 - https://github.com/taers232c/GAMADV-XTD3 +GAM 6.76.03 - https://github.com/taers232c/GAMADV-XTD3 Ross Scroggs Python 3.12.3 64-bit final MacOS Sonoma 14.4.1 x86_64 diff --git a/src/GamCommands.txt b/src/GamCommands.txt index bdde98a6..95a69d90 100644 --- a/src/GamCommands.txt +++ b/src/GamCommands.txt @@ -6245,7 +6245,7 @@ gam untrash drivefile gam info drivefile [returnidonly] - [filepath|fullpath] [pathdelimiter ] + [filepath|fullpath] [folderpathonly []] [pathdelimiter ] [allfields|*|(fields )] (orderby [ascending|descending])* [showdrivename] [showshareddrivepermissions] @@ -6728,7 +6728,7 @@ gam collect orphans gam show fileinfo [returnidonly] - [filepath|fullpath] [pathdelimiter ] + [filepath|fullpath] [folderpathonly []] [pathdelimiter ] [allfields|*|(fields )] (orderby [ascending|descending])* [showdrivename] [showshareddrivepermissions] @@ -6738,13 +6738,14 @@ gam show fileinfo [formatjson] gam show filepath - [returnidonly] + [returnpathonly] (orderby [ascending|descending])* - [stripcrsfromname] [fullpath] [pathdelimiter ] + [stripcrsfromname] + [fullpath] [folderpathonly []] [pathdelimiter ] gam print filepath [todrive *] (orderby [ascending|descending])* - [stripcrsfromname] [fullpath] [pathdelimiter ] - [oneitemperrow] + [stripcrsfromname] [oneitemperrow] + [fullpath] [folderpathonly []] [pathdelimiter ] gam print filecounts [todrive *] [((query ) | (fullquery ) | ) @@ -6838,7 +6839,7 @@ gam print filelist [todrive *] [countsonly [summary none|only|plus] [summaryuser ] [showsource] [showsize] [showmimetypesize]] [countsrowfilter] - [filepath|fullpath [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] + [filepath|fullpath [folderpathonly []] [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] [allfields|*|(fields )] [showdrivename] [showshareddrivepermissions] [(showlabels details|ids)|(includelabels )] diff --git a/src/GamUpdate.txt b/src/GamUpdate.txt index 77e9066a..716f23c5 100644 --- a/src/GamUpdate.txt +++ b/src/GamUpdate.txt @@ -2,6 +2,18 @@ Merged GAM-Team version +6.76.03 + +Added option `folderpathonly []` to the following commands that causes GAM +to display only the folder names when displaying the path to a file. This folder only path +an be used in `gam create drivefolderpath` to recreate the folder hierarchy. +``` +gam info drivefile ... filepath|fullpath +gam show fileinfo ... filepath|fullpath +gam print|show filepath +gam print filelist ... filepath|fullpath +``` + 6.76.02 Updated `gam update group` to handle the following error: diff --git a/src/gam/__init__.py b/src/gam/__init__.py index 0aa355d7..7c34f653 100755 --- a/src/gam/__init__.py +++ b/src/gam/__init__.py @@ -37796,6 +37796,7 @@ def _showSchema(schema, i=0, count=0): SCHEMA_FIELDTYPE_CHOICE_MAP = { 'bool': 'BOOL', + 'boolean': 'BOOL', 'date': 'DATE', 'double': 'DOUBLE', 'email': 'EMAIL', @@ -51540,7 +51541,8 @@ def doShowSharedDriveThemes(): def initFilePathInfo(delimiter): return {'ids': {}, 'allPaths': {}, 'localPaths': None, 'delimiter': delimiter} -def getFilePaths(drive, fileTree, initialResult, filePathInfo, addParentsToTree=False, fullpath=False, showDepth=False): +def getFilePaths(drive, fileTree, initialResult, filePathInfo, addParentsToTree=False, + fullpath=False, showDepth=False, folderPathOnly=False): def _getParentName(result): if (result['mimeType'] == MIMETYPE_GA_FOLDER) and result.get('driveId') and (result['name'] == TEAM_DRIVE): parentName = _getSharedDriveNameFromId(drive, result['driveId']) @@ -51594,7 +51596,8 @@ def getFilePaths(drive, fileTree, initialResult, filePathInfo, addParentsToTree= if depth > maxDepth: maxDepth = depth-1 fp.reverse() - fp.append(name) + if initialMimeType == MIMETYPE_GA_FOLDER or not folderPathOnly: + fp.append(name) filePaths.append(filePathInfo['delimiter'].join(fp)) else: maxDepth = _makeFilePaths(v, fplist, filePaths, name, maxDepth) @@ -51603,6 +51606,7 @@ def getFilePaths(drive, fileTree, initialResult, filePathInfo, addParentsToTree= filePaths = [] parents = initialResult.get('parents', []) + initialMimeType = initialResult['mimeType'] if parents: filePathInfo['localPaths'] = {} for parentId in parents: @@ -51612,7 +51616,7 @@ def getFilePaths(drive, fileTree, initialResult, filePathInfo, addParentsToTree= fplist = [] maxDepth = _makeFilePaths(filePathInfo['localPaths'], fplist, filePaths, initialResult['name'], -1) else: - if (fullpath and initialResult['mimeType'] == MIMETYPE_GA_FOLDER and + if (fullpath and initialMimeType == MIMETYPE_GA_FOLDER and ((initialResult['name'] == MY_DRIVE) or (initialResult.get('driveId') and initialResult['name'].startswith(SHARED_DRIVES)))): filePaths.append(initialResult['name']) @@ -52114,22 +52118,22 @@ def _formatFileDriveLabels(showLabels, labels, result, printMode, delimiter): # gam info drivefile # [returnidonly] -# [filepath|fullpath] [pathdelimiter ] +# [filepath|fullpath] [folderpathonly []] [pathdelimiter ] # [allfields|*|(fields )] [formatjson] # (orderby [ascending|descending])* # [showdrivename] [showshareddrivepermissions] # [(showlabels details|ids)|(includelabels )] # [showparentsidsaslist] -# [stripcrsfromname] +# [stripcrsfromname] [formatjson] # gam show fileinfo # [returnidonly] -# [filepath|fullpath] [pathdelimiter ] +# [filepath|fullpath] [folderpathonly []] [pathdelimiter ] # [allfields|*|(fields )] [formatjson] # (orderby [ascending|descending])* # [showdrivename] [showshareddrivepermissions] # [(showlabels details|ids)|(includelabels )] # [showparentsidsaslist] -# [stripcrsfromname] +# [stripcrsfromname] [formatjson] def showFileInfo(users): def _setSelectionFields(): _setSkipObjects(skipObjects, FILEINFO_FIELDS_TITLES, DFF.fieldsList) @@ -52138,7 +52142,7 @@ def showFileInfo(users): if getPermissionsForSharedDrives or DFF.showSharedDriveNames: _setSkipObjects(skipObjects, ['driveId'], DFF.fieldsList) - getPermissionsForSharedDrives = filepath = fullpath = returnIdOnly = showParentsIdsAsList = showNoParents = stripCRsFromName = False + getPermissionsForSharedDrives = filepath = fullpath = folderPathOnly = returnIdOnly = showParentsIdsAsList = showNoParents = stripCRsFromName = False pathDelimiter = '/' showLabels = None simpleLists = [] @@ -52150,13 +52154,15 @@ def showFileInfo(users): myarg = getArgument() if myarg == 'filepath': filepath = True + elif myarg == 'fullpath': + filepath = fullpath = True + elif myarg == 'folderpathonly': + folderPathOnly = getBoolean() + elif myarg == 'pathdelimiter': + pathDelimiter = getCharacter() elif myarg == 'showparentsidsaslist': showParentsIdsAsList = True simpleLists.append('parentsIds') - elif myarg == 'fullpath': - filepath = fullpath = True - elif myarg == 'pathdelimiter': - pathDelimiter = getCharacter() elif myarg == 'stripcrsfromname': stripCRsFromName = True elif myarg == 'showlabels': @@ -52257,7 +52263,8 @@ def showFileInfo(users): extendFileTree(fileTree, [result], None, False) extendFileTreeParents(drive, fileTree, pathFields) if not FJQC.formatJSON: - _, paths, _ = getFilePaths(drive, fileTree, result, filePathInfo, addParentsToTree=True, fullpath=fullpath) + _, paths, _ = getFilePaths(drive, fileTree, result, filePathInfo, addParentsToTree=True, + fullpath=fullpath, folderPathOnly=folderPathOnly) kcount = len(paths) printKeyValueList(['paths', kcount]) Ind.Increment() @@ -52265,7 +52272,8 @@ def showFileInfo(users): printKeyValueList(['path', path]) Ind.Decrement() else: - addFilePathsToInfo(drive, fileTree, result, filePathInfo, addParentsToTree=True) + addFilePathsToInfo(drive, fileTree, result, filePathInfo, + addParentsToTree=True, folderPathOnly=folderPathOnly) if fullpath: # Save simple parents list as mappings turn it into a list of dicts fpparents = result['parents'][:] @@ -52959,8 +52967,10 @@ def buildFileTree(feed, drive): fileTree[parentId]['children'].append(fileId) return fileTree -def addFilePathsToRow(drive, fileTree, fileEntryInfo, filePathInfo, csvPF, row, fullpath=False, showDepth=False): - _, paths, maxDepth = getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, fullpath=fullpath, showDepth=showDepth) +def addFilePathsToRow(drive, fileTree, fileEntryInfo, filePathInfo, csvPF, row, + fullpath=False, showDepth=False, folderPathOnly=False): + _, paths, maxDepth = getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, + fullpath=fullpath, showDepth=showDepth, folderPathOnly=folderPathOnly) kcount = len(paths) if showDepth: row['depth'] = maxDepth @@ -52975,8 +52985,9 @@ def addFilePathsToRow(drive, fileTree, fileEntryInfo, filePathInfo, csvPF, row, row[key] = path k += 1 -def addFilePathsToInfo(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=False): - _, paths, _ = getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=addParentsToTree, showDepth=False) +def addFilePathsToInfo(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=False, folderPathOnly=False): + _, paths, _ = getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=addParentsToTree, + showDepth=False, folderPathOnly=folderPathOnly) fileEntryInfo['paths'] = [] for path in sorted(paths): if GC.Values[GC.CSV_OUTPUT_CONVERT_CR_NL] and (path.find('\n') >= 0 or path.find('\r') >= 0): @@ -53550,7 +53561,7 @@ SIZE_FIELD_CHOICE_MAP = { # [countsonly [summary none|only|plus] [summaryuser ] # [showsource] [showsize] [showmimetypesize]] # [countsrowfilter] -# [filepath|fullpath [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] +# [filepath|fullpath [folderpathonly []] [pathdelimiter ] [addpathstojson] [showdepth]] [buildtree] # [allfields|*|(fields )] # [showdrivename] [showshareddrivepermissions] # (showlabels details|ids)|(includelabels )] @@ -53644,9 +53655,10 @@ def printFileList(users): fileInfo['driveName'] = _getSharedDriveNameFromId(drive, driveId) if filepath: if not FJQC.formatJSON or not addPathsToJSON: - addFilePathsToRow(drive, fileTree, fileInfo, filePathInfo, csvPF, row, fullpath=fullpath, showDepth=showDepth) + addFilePathsToRow(drive, fileTree, fileInfo, filePathInfo, csvPF, row, + fullpath=fullpath, showDepth=showDepth, folderPathOnly=folderPathOnly) else: - addFilePathsToInfo(drive, fileTree, fileInfo, filePathInfo) + addFilePathsToInfo(drive, fileTree, fileInfo, filePathInfo, folderPathOnly=folderPathOnly) if showParentsIdsAsList and 'parents' in fileInfo: fileInfo['parentsIds'] = fileInfo.pop('parents') if not GC.Values[GC.DRIVE_V3_NATIVE_NAMES]: @@ -53777,8 +53789,8 @@ def printFileList(users): csvPF = CSVPrintFile('Owner', indexedTitles=DRIVE_INDEXED_TITLES) FJQC = FormatJSONQuoteChar(csvPF) - addPathsToJSON = countsRowFilter = buildTree = countsOnly = filepath = fullpath = getPermissionsForSharedDrives = \ - mimeTypeInQuery = noRecursion = oneItemPerRow = stripCRsFromName = \ + addPathsToJSON = countsRowFilter = buildTree = countsOnly = filepath = fullpath = folderPathOnly = \ + getPermissionsForSharedDrives = mimeTypeInQuery = noRecursion = oneItemPerRow = stripCRsFromName = \ showParentsIdsAsList = showDepth = showParent = showSize = showMimeTypeSize = showSource = False sizeField = 'quotaBytesUsed' pathDelimiter = '/' @@ -53832,6 +53844,8 @@ def printFileList(users): filepath = True elif myarg == 'fullpath': filepath = fullpath = True + elif myarg == 'folderpathonly': + folderPathOnly = getBoolean() elif myarg == 'pathdelimiter': pathDelimiter = getCharacter() elif myarg == 'addpathstojson': @@ -54117,7 +54131,8 @@ def printFileList(users): userSvcNotApplicableOrDriveDisabled(user, str(e), i, count) break if fullpath: - getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=True, fullpath=fullpath, showDepth=showDepth) + getFilePaths(drive, fileTree, fileEntryInfo, filePathInfo, addParentsToTree=True, + fullpath=fullpath, showDepth=showDepth, folderPathOnly=folderPathOnly) if ((showParent and (fileEntryInfo['id'] not in {ORPHANS, SHARED_WITHME, SHARED_DRIVES})) or fileEntryInfo['mimeType'] != MIMETYPE_GA_FOLDER or noRecursion): if fileId not in filesPrinted: @@ -54413,17 +54428,18 @@ def printShowFileComments(users): # gam print filepaths [todrive *] # (orderby [ascending|descending])* -# [oneitemperrow] -# [stripcrsfromname] [fullpath] [pathdelimiter ] +# [stripcrsfromname] [oneitemperrow] +# [fullpath] [folderpathonly []] [pathdelimiter ] # gam show filepaths # [returnpathonly] # (orderby [ascending|descending])* -# [stripcrsfromname] [fullpath] [pathdelimiter ] +# [stripcrsfromname] +# [fullpath] [folderpathonly []] [pathdelimiter ] def printShowFilePaths(users): fileNameTitle = 'title' if not GC.Values[GC.DRIVE_V3_NATIVE_NAMES] else 'name' csvPF = CSVPrintFile(['Owner', 'id', fileNameTitle, 'paths'], 'sortall', ['paths']) if Act.csvFormat() else None fileIdEntity = getDriveFileEntity() - fullpath = oneItemPerRow = returnPathOnly = stripCRsFromName = False + fullpath = folderPathOnly = oneItemPerRow = returnPathOnly = stripCRsFromName = False pathDelimiter = '/' OBY = OrderBy(DRIVEFILE_ORDERBY_CHOICE_MAP) while Cmd.ArgumentsRemaining(): @@ -54432,6 +54448,8 @@ def printShowFilePaths(users): csvPF.GetTodriveParameters() elif myarg == 'fullpath': fullpath = True + elif myarg == 'folderpathonly': + folderPathOnly = getBoolean() elif myarg == 'pathdelimiter': pathDelimiter = getCharacter() elif myarg == 'stripcrsfromname': @@ -54492,7 +54510,8 @@ def printShowFilePaths(users): if fullpath: extendFileTree(fileTree, [result], None, False) extendFileTreeParents(drive, fileTree, pathFields) - entityType, paths, _ = getFilePaths(drive, fileTree, result, filePathInfo, addParentsToTree=True, fullpath=fullpath) + entityType, paths, _ = getFilePaths(drive, fileTree, result, filePathInfo, addParentsToTree=True, + fullpath=fullpath, folderPathOnly=folderPathOnly) if returnPathOnly: for path in paths: writeStdout(f'{path}\n')