Tjlejeune Posted March 21, 2019 Share Posted March 21, 2019 (edited) Need some help. I'm trying to set up unraid to move any folder larger than 5G in my download folder to a watch folder I have set up with the handbrake docker. Any one know how I can accomplish this? Edited March 21, 2019 by Tjlejeune Quote Link to comment
JoeUnraidUser Posted March 21, 2019 Share Posted March 21, 2019 (edited) Here is a script you can use. Just replace source and target with your folder paths. #!/bin/bash limit=4G source="/mnt/user/source" target="/mnt/user/target" limit=$(echo $limit | cut -d 'G' -f 1) for dir in "$source"/*/ do size=$(du -sBG "$dir" | cut -d 'G' -f 1) if (( $size > $limit )) then echo $size\G $dir \-\> $target mv "$dir" "$target" fi done moveDirBySize.sh Edited May 19, 2019 by JoeUnraidUser updated to handle spaces in folder names Quote Link to comment
Tjlejeune Posted March 22, 2019 Author Share Posted March 22, 2019 Thank you. Works as long as there's no spaces in the folder name Quote Link to comment
JoeUnraidUser Posted March 22, 2019 Share Posted March 22, 2019 (edited) 2 hours ago, Tjlejeune said: Thank you. Works as long as there's no spaces in the folder name Try it now. I updated it to handle spaces in folder names. Edited March 22, 2019 by JoeUnraidUser Quote Link to comment
Tjlejeune Posted March 22, 2019 Author Share Posted March 22, 2019 Oh, quotes were needed around $target. Tried fixing that myself but missed that. Thanks again Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.