Skip to content

Commit

Permalink
s
Browse files Browse the repository at this point in the history
  • Loading branch information
friosavila committed Jul 22, 2024
1 parent f2ad295 commit 1f8574f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
Binary file added python-stuff/datapath.exe
Binary file not shown.
42 changes: 42 additions & 0 deletions python-stuff/datapath.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import os
from pathlib import Path
import sys

def create_directory_tree(root_path, output_file, indent="", is_last=True):
root = Path(root_path)

output_file.write(f"{indent}{'└── ' if is_last else '├── '}{root.name}/\n")

indent += " " if is_last else "│ "

entries = list(root.iterdir())
entries.sort(key=lambda x: (not x.is_dir(), x.name.lower()))

file_extensions = set()

for i, entry in enumerate(entries):
if entry.is_dir():
create_directory_tree(entry, output_file, indent, i == len(entries) - 1)
else:
file_extensions.add(entry.suffix.lower() if entry.suffix else "(no extension)")

for i, ext in enumerate(sorted(file_extensions)):
is_last_ext = i == len(file_extensions) - 1
output_file.write(f"{indent}{'└── ' if is_last_ext else '├── '}*{ext}\n")

def main():
if len(sys.argv) > 1:
root_directory = sys.argv[1]
else:
root_directory = "."

output_filename = "directory_tree.txt"

with open(output_filename, 'w', encoding='utf-8') as output_file:
create_directory_tree(root_directory, output_file)

print(f"Directory tree has been saved to {output_filename}")
input("Press Enter to exit...")

if __name__ == "__main__":
main()
17 changes: 17 additions & 0 deletions python-stuff/files_path.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from pathlib import Path

def find_dta_files(root_path, output_file):
root = Path(root_path).resolve() # Get the absolute path

with open(output_file, 'w') as f:
for path in root.rglob('*.dta'):
relative_path = path.relative_to(root)
f.write(f"{relative_path}\n")

# Usage
root_directory = "." # Current directory
output_file = "dta_files_list.txt" # Name of the output file

find_dta_files(root_directory, output_file)
print(f"List of .dta files has been written to {output_file}")

0 comments on commit 1f8574f

Please sign in to comment.