Skip to main content

fs/README.md

1# fs
3These are scripts for manipulating files and folders in my local filesystem.
5## The individual scripts
7<!-- [[[cog
9# This adds the root of the repo to the PATH, which has cog_helpers.py
10from os.path import abspath, dirname
11import sys
13sys.path.append(abspath(dirname(dirname("."))))
15import cog_helpers
17folder_name = "fs"
19scripts = [
20 {
21 "name": "cdir.py",
22 "description": """
23 counts all the entries in subfolders under the working directory, and prints them in a table
24 <p><pre><code>$ cdir
25 37 fishconfig
26 48 repros
27 51 colossus-wheels
28 70 services
29 292 .git
30 -------
31 699</code></pre></p>
32 """
33 },
34 {
35 "usage": "deepestdir [ROOT]",
36 "description": "prints the directory which is the deepest child of the given directory"
37 },
38 {
39 "name": "flatten",
40 "description": """
41 flattens a directory structure.
42 When you run it in a folder, it moves any files in subfolders into the top-level folders, then deletes the now-empty folder.
43 """
44 },
45 {
46 "variants": ["hide [PATH]", "unhide [PATH]"],
47 "description": "alias for `chflags hidden PATH` and <code>chflags nohidden PATH</code>."
48 },
49 {
50 "name": "latest_download",
51 "description": "prints the path to the newest file in my Downloads folder"
52 },
53 {
54 "usage": "reveal PATH",
55 "description": "reveal the file/folder in the macOS Finder; alias for <code>open -R</code>"
56 },
57 {
58 "name": "sizes",
59 "description": """
60 gets the total size of all the files/folders under the working directory, and prints them in a table
61 <p><pre><code>$ sizes
62 512.00K aws/
63 520.00K wellcome/
64 1.54M images/
65 4.76M .git/
66 -------
67 7.58M ~/repos/scripts</code></pre></p>
68 """
69 },
72cog_helpers.create_description_table(folder_name=folder_name, scripts=scripts)
74]]]-->
75<dl>
76 <dt>
77 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/cdir.py">
78 <code>cdir.py</code>
79 </a>
80 </dt>
81 <dd>
82 counts all the entries in subfolders under the working directory, and prints them in a table
83 <p><pre><code>$ cdir
84 37 fishconfig
85 48 repros
86 51 colossus-wheels
87 70 services
88 292 .git
89 -------
90 699</code></pre></p>
91 </dd>
93 <dt>
94 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/deepestdir">
95 <code>deepestdir [ROOT]</code>
96 </a>
97 </dt>
98 <dd>
99 prints the directory which is the deepest child of the given directory
100 </dd>
102 <dt>
103 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/flatten">
104 <code>flatten</code>
105 </a>
106 </dt>
107 <dd>
108 flattens a directory structure.
109 When you run it in a folder, it moves any files in subfolders into the top-level folders, then deletes the now-empty folder.
110 </dd>
112 <dt>
113 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/hide">
114 <code>hide [PATH]</code>
115 </a>
117 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/unhide">
118 <code>unhide [PATH]</code>
119 </a>
120 </dt>
121 <dd>
122 alias for `chflags hidden PATH` and <code>chflags nohidden PATH</code>.
123 </dd>
125 <dt>
126 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/latest_download">
127 <code>latest_download</code>
128 </a>
129 </dt>
130 <dd>
131 prints the path to the newest file in my Downloads folder
132 </dd>
134 <dt>
135 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/reveal">
136 <code>reveal PATH</code>
137 </a>
138 </dt>
139 <dd>
140 reveal the file/folder in the macOS Finder; alias for <code>open -R</code>
141 </dd>
143 <dt>
144 <a href="https://github.com/alexwlchan/scripts/blob/main/fs/sizes">
145 <code>sizes</code>
146 </a>
147 </dt>
148 <dd>
149 gets the total size of all the files/folders under the working directory, and prints them in a table
150 <p><pre><code>$ sizes
151 512.00K aws/
152 520.00K wellcome/
153 1.54M images/
154 4.76M .git/
155 -------
156 7.58M ~/repos/scripts</code></pre></p>
157 </dd>
158</dl>
159<!-- [[[end]]] (sum: P2FdK3NhVa) -->