Comments (8)
It's easy to do so programatically. E.g. here is a simple Python script you can use: https://gist.github.com/dundee/97c4a609e9c2d4f7e4bb298bdde4df3a
gdu -f- | python3 abspath.py
from gdu.
The export format is compatible with the one of ncdu
. The absolute path is there just once in the "header", e.g.:
[1,2,{"progname":"gdu","progver":"development","timestamp":1666468251},
[{"name":"/home/dundee/work/gdu","mtime":1666468247},
The absolute paths of all files should be fairly simple to compose programmatically then.
Does this cover your use case?
from gdu.
Thanks for the answer dundee, I saw the header, I was hoping maybe there was an argument to output the whole path as it would make my use case so much easier than trying to reconstruct the whole path.
I will see what I can do to get the whole path.
from gdu.
Hm... if you have a scan of a whole drive with multiple levels, this becomes troublesome. Any chance a special flag to export the whole path is maybe possible?
from gdu.
What do you mean by multiple levels?
from gdu.
from gdu.
Didn't have the time to deal with it at the moment but kept coming back to this. I am not a developer, neither I write a lot of python, although I am familiar with it.
Thanks for providing an example. Using your example, I was able to create a similar code in powershell, which I provide below, for anyone that might need this in Windows Environment.
Although using Powershell 7+, this should run on any OS that is supported by version 7 of Powershell.
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[string]$jsonFile
)
function ConvertTo-FullPath {
param($data,
[string]$path)
if (-not ([string]::IsNullOrEmpty($path))) {
$path = "$($path)\$($data[0].Name)"
}
else {
$path = "$($path)$($data[0].Name)"
}
foreach ($item in ($data | Select -Skip 1) ) {
if ($item.GetType().BaseType.Name -eq "Array") {
ConvertTo-FullPath -data $item -path $path
}
else {
$pathLast = "$($path)\$($item.name)"
}
[void]$results.Add($pathLast)
}
}
$results = [System.Collections.ArrayList]@()
$data = Get-Content -Raw $jsonFile | ConvertFrom-Json
$fileInfo = Get-Item $jsonFile
$outputBaseName = $fileInfo.BaseName
$outputDirName = $fileInfo.DirectoryName
$outputFileName = "$($outputDirName)\$($outputBaseName).txt"
ConvertTo-FullPath -data $data[3] -path ''
$results | Out-File -FilePath $outputFileName -Encoding UTF8
Usage:
"C:\test\1.json" | C:\test\ConvertTo-FullPath.ps1
The script by default will output a txt file at the same path as the json.
It will have the same filename as the json file but with a txt extension.
The txt file will containthe fullpath of all the files.
I am usually using gdu to get all the filenames from a disk and then scan using LINQ for known filenames with CVEs, therefore having the wholepath is very helpful.
PS. There seems to be an issue with gdu or json formatting, which will cause the filepath that was picked to run gdu against to have an extra trailing backslash. This will also be present at the output. I couldn't care less about an extra backslash being therefore I am leaving it as it is.
Once again thanks for your work here.
from gdu.
Thanks for sharing!
from gdu.
Related Issues (20)
- Application crash on WSL in the mounted disks screen HOT 5
- tiny enhancement: always (try to) change directory HOT 1
- Add `h` and `l` as left/right keys for `d` (delete) menu confirmation
- Dismissing help menu coming from delete menu makes it impossible to select delete menu options
- [Question] Is there a way to limit the max depth of scanning? HOT 2
- Make key based settings/toggles available through config/command-line HOT 1
- add parallel-disk-usage to benchmark
- feat: add ctrl+z for job control support HOT 4
- Strange behavior when returning from CTRL-Z - 5.24.0 HOT 14
- How about higher resolution size bar ? HOT 4
- gdu not display location of symlinks ?
- Feature: add a mode for visualizing inodes distribution on the disk HOT 2
- Windows version includes files synced from OneDrive/Sharepoint in space calculations
- gdu with ssh won't close, 100 percent cpu usage HOT 4
- Is possible to add feature to remove all hardlinks? HOT 1
- Try building with PGO HOT 1
- feature: sort by create/update date HOT 1
- Windows NTFS drive mounted in linux infinitely traverses symlinks without -L flag
- Error When Pressing Right Key in Empty Folder: Panic with Interface Conversion Nil Error
- Windows Instructions to fix: `bash: gdu: command not found` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gdu.