Last active
January 18, 2023 22:38
Revisions
-
greencoder revised this gist
Jan 18, 2023 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ import pathlib import random import shutil -
greencoder created this gist
Jan 18, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ import glob import pathlib import random import shutil mp3_files = list(pathlib.Path('/Users/scott/Desktop/Music').rglob('*.mp3')) dst_dir = pathlib.Path('/Users/snewman/Desktop/CopiedMusic') TARGET_SIZE = 1979999999 for x in range(0, len(mp3_files)): src_file = random.choice(mp3_files) dst_file = dst_dir / src_file.name shutil.copyfile(src_file, dst_file) directory_size = sum(f.stat().st_size for f in dst_dir.glob('*.mp3') if f.is_file()) if directory_size < TARGET_SIZE: continue