Skip to main content

Never mind explorer.exe, here is dirdf

Are you one of those people who have never any space on their hard disk? Do you spend hours and hours searching for your files because you never remember where you saved them? Well, since I am one of those, I tried several tools in the past: TreeSize / WinDirStat / WizTree / SpaceSniffer / GREP. They all are great,

but take forever to get the job done and only offer limited filter functions. Around 5 hours ago, after having searched around 30 minutes for a file on my hard drive, I decided to do something about it ...

Install the package (Windows only)

pip install dirdf

Install Cygwin (ls.exe is necessary for getting the file list)

ls.exe.

Tools needed for some functions

strings.exe.

rg.exe.

fzf.exe.

from dirdf import pd_add_dfdir

pd_add_dfdir()

import pandas as pd



df = pd.Q_folder_to_df(

    folder=r"C:\Users\blabla",

    ls_path="ls",

    last_access_time=True,

    exit_keys="ctrl+x",

    timeout=None,

)

df2 = pd.Q_folder_to_df_with_functions(

    folder=r"C:\Users\blabla",

    ls_path="ls",

    last_access_time=True,

    exit_keys="ctrl+x",

    timeout=None,

    strings_path="strings",

    fzf_path="fzf",

    rip_grep_path="rg.exe",

    add_flatcopy_sorted=True,

    add_flatcopy=True,

    add_extract_strings=True,

    add_fuzzy_extract=True,

    add_ripgrep=True,

    add_open_file=True,

    add_move_file=True,

)



# Some examples



# Flatcopy - foldersep='ǀ' means that the backslash ‘\’ will be replaced by 'ǀ'. The replacement is important because there is no “flat copy” with a backslash in the path! All file types (pdf, jpg ... ) will get their own folder. If you want to save space, create a symlink instead of copying the whole file 

df.loc[df.aa_fullpath.str.contains(r'\.txt|\.docx|\.jpg')][:100].ff_flatcopy_sorted.apply(lambda x:x('f:\\testflatcopy_df', foldersep='ǀ', symlink=False, copystat=True))

df.loc[df.aa_fullpath.str.contains(r'\.txt|\.docx|\.jpg')][:100].ff_flatcopy_sorted.apply(lambda x:x('f:\\testflatcopy_df\\symlink', foldersep='ǀ', symlink=True, copystat=True)) # copystat will be ignored in this case



# Flatcopy without sorting file types

df.loc[df.aa_fullpath.str.contains(r'\.txt')][2:100].ff_flatcopy.apply(lambda x:x('f:\\newfoldertest\\flatcopy'))

df.loc[df.aa_fullpath.str.contains(r'\.txt')][2:100].ff_flatcopy.apply(lambda x:x('f:\\newfoldertest\\flatcopy\\sym',symlink=True))



# Extract all strings from any file 

df.loc[df.aa_fullpath.str.contains(r'\.txt')][:100].ff_extract_strings.apply(lambda x:x(exit_keys='ctrl+x', print_output=True, timeout=None))



# Fuzzy search in any file

df.loc[df.aa_fullpath.str.contains(r'\.txt')][:100].ff_fuzzy.apply(lambda x:x('windows'))



# Regex search in any file

df.loc[df.aa_fullpath.str.contains(r'\.txt')][:100].ff_ripgrep.apply(lambda x:x(regular_expression='name', other_parameters='-i', exit_keys='ctrl+x', print_output=True, timeout=.1))



# Executes os.startfile()

df.loc[df.aa_fullpath.str.contains(r'\.txt')][:100].iloc[0].ff_open()



# Moves files, keeps the folder structur

df.loc[df.aa_fullpath.str.contains(r'\.txt')][:1].ff_move_file.apply(lambda x:x('f:\\newfoldertest'))





df

Out[3]: 

                               aa_date  ... aa_filetype

0  2022-10-23 12:18:58.767317900-03:00  ...          .0

1  2022-10-23 05:48:51.755017400-03:00  ...       .yaml

2  2022-10-23 05:51:47.520702700-03:00  ...        .jpg

3  2022-10-23 05:51:46.817189600-03:00  ...        .jpg

4  2022-10-23 05:48:51.755017400-03:00  ...       .yaml

5  2022-10-23 12:18:58.767317900-03:00  ...        .csv

6  2022-10-23 05:51:49.630625800-03:00  ...        .jpg

7  2022-10-23 05:51:52.116036400-03:00  ...        .jpg

8  2022-10-23 05:51:52.678404900-03:00  ...        .jpg

9  2022-10-23 13:31:03.003835900-03:00  ...         NaN

10 2022-10-23 12:18:59.267762600-03:00  ...         .pt

11 2022-10-23 06:00:01.068658100-03:00  ...         .pt

12 2022-10-23 07:23:56.117463800-03:00  ...         .pt

13 2022-10-23 08:53:33.799414100-03:00  ...         .pt

14 2022-10-23 12:18:59.048534200-03:00  ...         .pt

[15 rows x 14 columns]

df2

Out[4]: 

                               aa_date  ...                                        ff_flatcopy

0  2022-10-23 12:18:58.767317900-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

1  2022-10-23 05:48:51.755017400-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

2  2022-10-23 05:51:47.520702700-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

3  2022-10-23 05:51:46.817189600-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

4  2022-10-23 05:48:51.755017400-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

5  2022-10-23 12:18:58.767317900-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

6  2022-10-23 05:51:49.630625800-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

7  2022-10-23 05:51:52.116036400-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

8  2022-10-23 05:51:52.678404900-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

9  2022-10-23 13:31:03.003835900-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

10 2022-10-23 12:18:59.267762600-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

11 2022-10-23 06:00:01.068658100-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

12 2022-10-23 07:23:56.117463800-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

13 2022-10-23 08:53:33.799414100-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

14 2022-10-23 12:18:59.048534200-03:00  ...  dest_folder:str, foldersep:str='ǀ', symlink:bo...

[15 rows x 21 columns]

Metadata

Release files for dirdf 0.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dirdf 0.11
File Size Uploaded Provenance Actions
dirdf-0.11.tar.gz 10.6 kB Without provenance Details for dirdf-0.11.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dirdf 0.11
File Interpreter ABI Platform Actions
dirdf-0.11-py3-none-any.whl Python 3 none any Details for dirdf-0.11-py3-none-any.whl

Total release size: 21.7 kB

Release files / dirdf-0.11.tar.gz

Download URL dirdf-0.11.tar.gz
Size 10.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e5e0be03af0f11f2f28ab3f9eb3a75cfa0542925035b5e78fb1216a8eb8f28e2
BLAKE2b-256 checksum
How to use checksums
773171a39baaf96381c01a5505c1126abefccb90e34c41bd167e19503f9c3a37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / dirdf-0.11-py3-none-any.whl

Download URL dirdf-0.11-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
70cada75b3b1704eb6e79e479f4364f2bdb97132cce06b6f6a620f77958007c1
BLAKE2b-256 checksum
How to use checksums
f78e133c1cb761d1fcbdd5b3bb0bab1f838f69dba45e2e9a67285800f506d34a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Security for dirdf 0.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.11 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page