Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Don't use the force (-f) option. You'll be prompted for y or n for each deletion, just answer n when asked to decend into the uploads/ folder
Obviously tedious if there are a lot of files in folder4/, or many other sub-folders besides uploads/
I've taken to almost never using the -f option from the command line...you get no information about what has been deleted, and no error messages. Very risky thing to use.
Moving a folder should be a blink, no matter what the size, because (if I understand correctly) mv doesn't actually relocate the folder, just changes the pointer to it in the metadata. I don't have really big folder or file to confirm that with, tho. Copying (cp) is different, as the files are relocated. Try it out. Let us know what you experience.
And yes, not using -f would be tedious for a large number of files, as I said.
Moving a folder should be a blink, no matter what the size, because (if I understand correctly) mv doesn't actually relocate the folder, just changes the pointer to it in the metadata. I don't have really big folder or file to confirm that with, tho. Copying (cp) is different, as the files are relocated. Try it out. Let us know what you experience.
And yes, not using -f would be tedious for a large number of files, as I said.
that is only if it is on the same partition, is moves really fast, but if one needs to relocate to another partition or drive, it copies, then deletes the original. which takes a lot longer.
If my uploads folder is 400GB and my disk size is 500GB it will work to move it on another directory or it will need to allocate first the full size and then to free it as that will not work?
you could go down into that dir, then just move a few at a time, if not one at a time until you've freed up enough to do a move all of these at the "same time" command. if and or it gets to that point.
The move command will delete the source file when it is done moving it, so you can pick up where you left off easier. In case you have to stop for whatever reason, and pick up where you left off at a later date.
remember the move command in Linux operates like this, (probably windows and MAC too) copy to destination then remove source if you are crossing partitions. If not it just writes the "new" location to the MFT (master file table), or whatever "they" decided to call it on the disk if you are staying in the same partition. which is a lot faster.
with approx 100GB free space. you might want to start with move a few at a time. even though in all reality it does one at a time, using a list of what you told it to move for reference.
you could ever write a little script to move x amount of files at a time. then stop, then just run it again unto you've freed up enough space to do a move all of these at once command. Using a file manager or command line or script.
a script to use if you want to.
Code:
#!/bin/bash
source_files=
destination=
count=0
#if one tries to run it without first telling it how many files to move
#it will tell op (operator) that message then exit.
[[ "$1" -lt '1' ]] && (echo "add amount to move" ; exit )
while read F && [[ $count -lt $1 ]] ;
do
c=$F
xpath=${c%/*}
xbase=${c##*/}
xfext=${xbase##*.}
xpref=${xbase%.*}
#to see what each one does
echo $xpath
echo $xbase
echo $xpref
echo $xfext
#Creates destination directory(ies) and sub-directory
#by the same name as the file
mkdir -p "$destination"/"$xpref"
echo "mv -v "$F" "$destination"/"$xpref" "
((count++))
done<<<"$(find "$source_files" -type f -name "*.mp4" -o -name "*.mkv" -o -name "*.avi")"
just add whatever file types you want and mod it to how ever you want if you want to use it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.