diskusagereports icon indicating copy to clipboard operation
diskusagereports copied to clipboard

new options needed

Open Picar66 opened this issue 12 years ago • 8 comments

please inclue a Switch to disable writing the Headline. With this someone could concatinate the results to a "virtual" scanfileresultfile from different places.

Next wish is to include a Prefixdir for the Output filenameinfo in result. With this the result can be put into a "Prefixdirectory". scan1 on c:\dir1 Output is: Headline dir dir\file1

Scan2 on c:\dir2 Output is: headline file2

concat this is not good in Report with Option -nh (no Headline) an -p "dir2" Output of scan2 would be dir2\file2

concat this will Show in Report: dir1\dir\file1 dir2\file2

that is better. so we can make a report from differnt server directorys put into one logical/virtual Report

Picar66 avatar Apr 23 '13 23:04 Picar66

What do you mean by "headline"? Are you referring about the settings.txt report file?

amekkawi avatar Apr 23 '13 23:04 amekkawi

no. find exe Output has a "Headline" beginning with ##.... the first Output is what i mean with "headline"

if i can omit this i can concat the Output from different find.exe runs to one great outputfile for reportinput.

Picar66 avatar Apr 23 '13 23:04 Picar66

You can use a win32 port (such as http://gnuwin32.sourceforge.net/packages/coreutils.htm) of the *nix "tail" command to achieve these.

The following command would output all but the first line from find.exe: find.exe c:\path\to\some\dir | tail -n +2 > find-output-no-headline.dat

amekkawi avatar Apr 23 '13 23:04 amekkawi

ok this will work. but nicer is a switch to tell find.exe not to produce this line.

found a "build-in" solution with more +1 find.exe c:\path\to\some\dir | more +1 >find-output-no-headline.dat

Picar66 avatar Apr 23 '13 23:04 Picar66

Ah ok. Now I understand the prefix request as well. The obvious problem with just concatinating the output of two find.exe calls is when both the directories being scanned have directories or files with the same names directly in them.

For example if the first directory had the following contents:

  • images
  • js
  • index.html
  • aboutus.html

and the second directory had the following:

  • images
  • javascript
  • default.html
  • aboutus.html

From the perspective of process.php there would be two "images" directories and two "aboutus.html" files within the same directory.

To fix this you would need to prefix the file paths with something to create the illusion that each of the directories scanned was under some other directory.

To do this you could again use win32 ports of the *nix awk or sed command.

For example: find.exe c:\path\to\some\dir | tail -n +2 | sed -e "s/^/dir1\\/" > find-output-no-headline-with-prefix.dat or find.exe c:\path\to\some\dir | tail -n +2 | awk '{ print "dir1\\" $0; }' > find-output-no-headline-with-prefix.dat

I tested these on Mac OS X and they'd likely need some adjustment to work in the DOS command line as quotes are handled differently.

Here would be a complete example using sed: find.exe c:\path\to\some\dir1 | sed -e "s/^/dir1\\/" > find.dat find.exe c:\path\to\some\dir2 | tail -n +2 | sed -e "s/^/dir2\\/" >> find.dat find.exe c:\path\to\some\dir3 | tail -n +2 | sed -e "s/^/dir3\\/" >> find.dat

I only removed the headline from the second and third calls.

amekkawi avatar Apr 23 '13 23:04 amekkawi

To expand on using builtin Windows command line tools, the example Windows batch script below would combine removing the headline and prefixing lines with a directory name.

@echo off
setlocal
for /F "tokens=*" %%a in ('more +%2') do (
    echo %1\%%a
)

Usage example: find.exe c:\path\to\some\dir1 | examplescript.bat dir1 0 > find.dat find.exe c:\path\to\some\dir2 | examplescript.bat dir2 1 >> find.dat find.exe c:\path\to\some\dir3 | examplescript.bat dir3 1 >> find.dat

Again I only removed the headline from the second and third calls.

amekkawi avatar Apr 24 '13 00:04 amekkawi

The output is wrong. normal outputline is [type] [date] [time] [size] [dirandfilename]\cr\lf example.bat produces: dir1[type] [date] [time] [size] [dirandfilename]\cr\lf needed: [type] [date] [time] [size] [prefixdir][dirandfilename]\cr\lf

Batch must be: @echo off setlocal for /f "tokens=1,2,3,4,*" %%a in ('more +%2') do ( echo %%a %%b %%c %%d %1%%e )

Hopefull the for /f loop would not change UTF8 characterset. Have to test this.

Picar66 avatar Apr 24 '13 07:04 Picar66

If a file or directoy is named like a command e.g. miles&more this batch would stop correct precessing cause interpreting this & more as a command. Shit.

Do you find it impossible to do this nice thing with an extra switch?

Picar66 avatar Apr 24 '13 08:04 Picar66