Move large folders with script


Recommended Posts

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 by JoeUnraidUser
updated to handle spaces in folder names
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.