Skip to content

Instantly share code, notes, and snippets.

@Nanodragon999
Created June 11, 2019 21:57
Show Gist options
  • Save Nanodragon999/ba4c38f0aaaa7c1c32c7cee862c5cc71 to your computer and use it in GitHub Desktop.
Save Nanodragon999/ba4c38f0aaaa7c1c32c7cee862c5cc71 to your computer and use it in GitHub Desktop.
target_number=1
target_folder="folder "$target_number"/"
#set up the switch folder function, not working correctly yet though
file_count=$(expr $(\ls ${target_folder} | wc -l) - 3) #count the number of files, too slow so need to remplace with counting transfer.
inotifywait -m -q -e close_write --format %f . | while IFS= read -r file; do
#watch a directory/folder for files that have their file descriptor closed, then read the filename of the file printed by inotifywait.
if [ file_count=>400000 ]; then
#if the file count exceed 400k (or transfer in the preferred case)
#change folder here
target_number=$((target_number + 1))
#folder scheme is mostly folder1 folder2 etc
file_count=$(expr $(\ls ${target_folder} | wc -l) - 3)
#used the same function twice, i'm dumb
fi
move ${file} ${target_folder}
#move files but really can be doing anything else than this
file_count=$(expr $file_count + 1)
#i think i might need to delete that, not sure
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment