ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/ns_dev/Python/NinoCode/Active_prgs/Redgrave/Lilly-PathAnalysis.py
Revision: 935
Committed: Thu Aug 7 20:38:27 2025 UTC (7 months, 2 weeks ago) by nino.borges
Content type: text/x-python
File size: 1926 byte(s)
Log Message:
Very simple program that will perform some custom analysis on large directory tree dumps in a log file.

File Contents

# User Rev Content
1 nino.borges 935 """
2    
3     Lilly-PathAnalysis
4    
5     Created by:
6     Emanuel Borges
7     11.12.2024
8    
9     Very simple program that will perform some custom analysis on large directory tree dumps in a log file.
10    
11     """
12    
13     import os
14    
15    
16    
17    
18    
19     if __name__ == '__main__':
20     inputLogFileName = r"C:\Test_Dir\Lilly\ly3298176_listing.log"
21     #inputLogFileName = r"C:\Test_Dir\Lilly\test.txt"
22     outputLogFileName = r"C:\Test_Dir\Lilly\ly3298176_listing(processed).log"
23    
24    
25     contents = open(inputLogFileName,encoding='utf8').readlines()
26     outputFile = open(outputLogFileName,'w', encoding='utf8')
27     prevLonePath = ""
28    
29    
30     for line in contents:
31     line = line.replace("\n","")
32     fExt = os.path.splitext(line)[-1]
33     if fExt:
34     ## Assume this is a full path with file
35     dirPath,fName = os.path.split(line)
36     dirPathParts = dirPath.split("/")
37     dirFirstPart = "/".join(dirPathParts[0:4])
38     if len(dirPathParts)> 4:
39     dirSecondPart = "/".join(dirPathParts[4:])
40     else:
41     dirSecondPart = ""
42     if prevLonePath:
43    
44     outputFile.write(f"{dirFirstPart}|{dirSecondPart}|{fName}|{fExt}|\n")
45     prevLonePath = ""
46    
47     else:
48     ## This is probably a path only but test it.
49     if prevLonePath:
50     if line.split("/")[-2] == prevLonePath.split("/")[-1]:
51     pass
52     else:
53     dirPathParts = prevLonePath.split("/")
54     dirFirstPart = "/".join(dirPathParts[0:4])
55     if len(dirPathParts)> 4:
56     dirSecondPart = "/".join(dirPathParts[4:])
57     else:
58     dirSecondPart = ""
59     outputFile.write(f"{dirFirstPart}|{dirSecondPart}|||POSSIBLE FILE\n")
60     prevLonePath = line
61    
62     outputFile.close()