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.
@@ -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
@@ -31,6 +31,8 @@ Commands:
31
31
 
32
32
  - `curltime`: Measures request response timings
33
33
  - `gif`: Video to GIF
34
+
35
+ - `flattendir`: Moves all files to top dir and deletes dirs
34
36
  <br/>
35
37
 
36
38
  ### Converting Images to AVIF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasnacks",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Utilities for preparing videos, images, and audio for the web",
5
5
  "license": "MIT",
6
6
  "author": "Eric Fortis",
package/src/cli.js CHANGED
@@ -28,6 +28,7 @@ const COMMANDS = {
28
28
 
29
29
  curltime: ['curltime.sh', 'Measures request response timings'],
30
30
  gif: ['gif.sh', 'Video to GIF'],
31
+ flattendir: ['flattendir.py', 'Moves all files to top dir and deletes dirs']
31
32
  }
32
33
 
33
34
  const USAGE = `
@@ -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()