mediasnacks 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.zsh/completions/_mediasnacks +3 -2
- package/README.md +2 -0
- package/package.json +1 -1
- package/src/cli.js +1 -0
- package/src/flattendir.py +23 -0
|
@@ -16,7 +16,8 @@ _mediasnacks_commands=(
|
|
|
16
16
|
'unemoji:Removes emojis from filenames'
|
|
17
17
|
'rmcover:Removes cover art'
|
|
18
18
|
'curltime:Measures request response timings',
|
|
19
|
-
'gif:Video to GIF'
|
|
19
|
+
'gif:Video to GIF',
|
|
20
|
+
'flattendir:Moves all files to top dir and deletes dirs'
|
|
20
21
|
)
|
|
21
22
|
|
|
22
23
|
_mediasnacks() {
|
|
@@ -27,7 +28,7 @@ _mediasnacks() {
|
|
|
27
28
|
|
|
28
29
|
local cmd="$words[2]"
|
|
29
30
|
case "$cmd" in
|
|
30
|
-
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime|gif)
|
|
31
|
+
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|flattendir)
|
|
31
32
|
_files
|
|
32
33
|
;;
|
|
33
34
|
qdir)
|
package/README.md
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def flatten_dir(folder=Path().cwd()):
|
|
8
|
+
"""Moves all files to top dir and deletes dirs"""
|
|
9
|
+
|
|
10
|
+
for path in folder.rglob('*'):
|
|
11
|
+
if path.is_file():
|
|
12
|
+
dest = folder / path.name
|
|
13
|
+
if dest.exists():
|
|
14
|
+
dest = folder / f'{path.stem}__{path.stat().st_mtime_ns}{path.suffix}'
|
|
15
|
+
shutil.move(str(path), str(dest))
|
|
16
|
+
|
|
17
|
+
for sub in sorted(folder.rglob('*'), reverse=True):
|
|
18
|
+
if sub.is_dir() and not any(sub.iterdir()):
|
|
19
|
+
sub.rmdir()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == '__main__':
|
|
23
|
+
flatten_dir()
|