Added option folderpathonly [<Boolean>] to commands that display paths

This commit is contained in:
Ross Scroggs
2024-05-17 07:42:32 -07:00
parent f94afedfa8
commit 5a5b98cccb
9 changed files with 123 additions and 61 deletions

View File

@@ -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 [<EmailAddress>] [project <ProjectID>]
```

View File

@@ -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 [<Boolean>]` 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 <UserTypeEntity> create drivefolderpath` to recreate the folder hierarchy.
```
gam <UserTypeEntity> info drivefile ... filepath|fullpath
gam <UserTypeEntity> show fileinfo ... filepath|fullpath
gam <UserTypeEntity> print|show filepath
gam <UserTypeEntity> print filelist ... filepath|fullpath
```
### 6.76.02
Updated `gam update group` to handle the following error:

View File

@@ -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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
Python 3.12.3 64-bit final
Windows-10-10.0.17134 AMD64

View File

@@ -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/
* 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

View File

@@ -396,7 +396,7 @@ Display file details in indented keyword: value format. The two forms are equiva
```
gam <UserTypeEntity> show fileinfo <DriveFileEntity>
[returnidonly]
[filepath|fullpath] [pathdelimiter <Character>]
[filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[showdrivename] [showshareddrivepermissions]
@@ -406,7 +406,7 @@ gam <UserTypeEntity> show fileinfo <DriveFileEntity>
[formatjson]
gam <UserTypeEntity> info drivefile <DriveFileEntity>
[returnidonly]
[filepath|fullpath] [pathdelimiter <Character>]
[filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[showdrivename] [showshareddrivepermissions]
@@ -421,6 +421,10 @@ Use `filepath` to display the path(s) to the files in `<DriveFileEntity>`.
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 <UserTypeEntity> create drivefolderpath` to recreate the folder hierarchy.
By default, file path components are separated by `/`; use `pathdelimiter <Character>` to use `<Character>` 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 <UserTypeEntity> show filepath <DriveFileEntity>
[returnpathonly]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[stripcrsfromname] [fullpath] [pathdelimiter <Character>]
[stripcrsfromname]
[folderpathonly [<Boolean>]] [fullpath] [pathdelimiter <Character>]
gam <UserTypeEntity> print filepath <DriveFileEntity> [todrive <ToDriveAttribute>*]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[stripcrsfromname] [fullpath] [pathdelimiter <Character>]
[oneitemperrow]
[stripcrsfromname] [oneitemperrow]
[fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
```
Use `returnpathonly` to display just the file path of the files in `<DriveFileEntity>`.
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 <UserTypeEntity> create drivefolderpath` to recreate the folder hierarchy.
By default, file path components are separated by `/`; use `pathdelimiter <Character>` to use `<Character>` as the separator.
The `stripcrsfromname` option strips nulls, carriage returns and linefeeds from drive file names.
@@ -1009,8 +1018,9 @@ gam <UserTypeEntity> print|show filelist [todrive <ToDriveAttribute>*]
[excludetrashed]
[maxfiles <Integer>] [nodataheaders <String>]
[countsonly [summary none|only|plus] [summaryuser <String>]
[showsource] [showsize] [showmimetypesize]] [countsrowfilter]
[filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[showsource] [showsize] [showmimetypesize]]
[countsrowfilter]
[filepath|fullpath [folderpathonly [<Boolean>]] [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
[showdrivename] [showshareddrivepermissions]
[(showlabels details|ids)|(includelabels <DriveLabelIDList>)]
@@ -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 <FieldName> <String>` - 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 <FieldName> <String>` - 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 <UserTypeEntity> create drivefolderpath` to recreate the folder hierarchy.
By default, file path components are separated by `/`; use `pathdelimiter <Character>` to use `<Character>` as the separator.
By default, only the fields `id` and `webViewLink` are displayed.

View File

@@ -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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
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 <ross.scroggs@gmail.com>
Python 3.12.3 64-bit final
MacOS Sonoma 14.4.1 x86_64

View File

@@ -6245,7 +6245,7 @@ gam <UserTypeEntity> untrash drivefile <DriveFileEntity>
gam <UserTypeEntity> info drivefile <DriveFileEntity>
[returnidonly]
[filepath|fullpath] [pathdelimiter <Character>]
[filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[showdrivename] [showshareddrivepermissions]
@@ -6728,7 +6728,7 @@ gam <UserTypeEntity> collect orphans
gam <UserTypeEntity> show fileinfo <DriveFileEntity>
[returnidonly]
[filepath|fullpath] [pathdelimiter <Character>]
[filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[showdrivename] [showshareddrivepermissions]
@@ -6738,13 +6738,14 @@ gam <UserTypeEntity> show fileinfo <DriveFileEntity>
[formatjson]
gam <UserTypeEntity> show filepath <DriveFileEntity>
[returnidonly]
[returnpathonly]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[stripcrsfromname] [fullpath] [pathdelimiter <Character>]
[stripcrsfromname]
[fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
gam <UserTypeEntity> print filepath <DriveFileEntity> [todrive <ToDriveAttribute>*]
(orderby <DriveFileOrderByFieldName> [ascending|descending])*
[stripcrsfromname] [fullpath] [pathdelimiter <Character>]
[oneitemperrow]
[stripcrsfromname] [oneitemperrow]
[fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
gam <UserTypeEntity> print filecounts [todrive <ToDriveAttribute>*]
[((query <QueryDriveFile>) | (fullquery <QueryDriveFile>) | <DriveFileQueryShortcut>)
@@ -6838,7 +6839,7 @@ gam <UserTypeEntity> print filelist [todrive <ToDriveAttribute>*]
[countsonly [summary none|only|plus] [summaryuser <String>]
[showsource] [showsize] [showmimetypesize]]
[countsrowfilter]
[filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[filepath|fullpath [folderpathonly [<Boolean>]] [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
[allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
[showdrivename] [showshareddrivepermissions]
[(showlabels details|ids)|(includelabels <DriveLabelIDList>)]

View File

@@ -2,6 +2,18 @@
Merged GAM-Team version
6.76.03
Added option `folderpathonly [<Boolean>]` 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 <UserTypeEntity> create drivefolderpath` to recreate the folder hierarchy.
```
gam <UserTypeEntity> info drivefile ... filepath|fullpath
gam <UserTypeEntity> show fileinfo ... filepath|fullpath
gam <UserTypeEntity> print|show filepath
gam <UserTypeEntity> print filelist ... filepath|fullpath
```
6.76.02
Updated `gam update group` to handle the following error:

View File

@@ -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 <UserTypeEntity> info drivefile <DriveFileEntity>
# [returnidonly]
# [filepath|fullpath] [pathdelimiter <Character>]
# [filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
# [allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)] [formatjson]
# (orderby <DriveFileOrderByFieldName> [ascending|descending])*
# [showdrivename] [showshareddrivepermissions]
# [(showlabels details|ids)|(includelabels <DriveLabelIDList>)]
# [showparentsidsaslist]
# [stripcrsfromname]
# [stripcrsfromname] [formatjson]
# gam <UserTypeEntity> show fileinfo <DriveFileEntity>
# [returnidonly]
# [filepath|fullpath] [pathdelimiter <Character>]
# [filepath|fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
# [allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)] [formatjson]
# (orderby <DriveFileOrderByFieldName> [ascending|descending])*
# [showdrivename] [showshareddrivepermissions]
# [(showlabels details|ids)|(includelabels <DriveLabelIDList>)]
# [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 <String>]
# [showsource] [showsize] [showmimetypesize]]
# [countsrowfilter]
# [filepath|fullpath [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
# [filepath|fullpath [folderpathonly [<Boolean>]] [pathdelimiter <Character>] [addpathstojson] [showdepth]] [buildtree]
# [allfields|<DriveFieldName>*|(fields <DriveFieldNameList>)]
# [showdrivename] [showshareddrivepermissions]
# (showlabels details|ids)|(includelabels <DriveLabelIDList>)]
@@ -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 <UserTypeEntity> print filepaths <DriveFileEntity> [todrive <ToDriveAttribute>*]
# (orderby <DriveFileOrderByFieldName> [ascending|descending])*
# [oneitemperrow]
# [stripcrsfromname] [fullpath] [pathdelimiter <Character>]
# [stripcrsfromname] [oneitemperrow]
# [fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
# gam <UserTypeEntity> show filepaths <DriveFileEntity>
# [returnpathonly]
# (orderby <DriveFileOrderByFieldName> [ascending|descending])*
# [stripcrsfromname] [fullpath] [pathdelimiter <Character>]
# [stripcrsfromname]
# [fullpath] [folderpathonly [<Boolean>]] [pathdelimiter <Character>]
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')