![]() Registered Member ![]()
|
I've had alot of problems using KDE to organize my files. I have several directories with over 100,000 files in them, and dolphin hangs when even opening the folder, let alone moving the files or clicking on anything. So, I was looking into using the command line as a more powerful way to handle my files, but I have a few questions.
Whats the best way to move all the files from one directory to another?
Is this the best way? And a big question. Is it possible to move the first 20,000 (or X number) files from a directory to another directory? Its impossible to open directories with so many files so Id like to break it into chunks but I want to keep the order the files are in. Thanks for your help, -Supreme1012 |
![]() Manager ![]()
|
Not exactly answering your question, but something that I've often found useful. If a large number of files is involved it seems to be very much quicker to copy them to the new location, then select all and delete them as a batch. I could be wrong, but I suspect that mv copies the file then deletes it then reads the next file, and so on.
annew, proud to be a member of KDE forums since 2008-Oct and a KDE user since 2002.
Join us on http://userbase.kde.org |
![]() Registered Member ![]()
|
that depends on where the files are moved to.
if the files stay on the same filesystem, the mv command simply renames them.
Riinse, proud to be a member of KDE forums since 2008-Oct.
|
![]() Manager ![]()
|
True - I was thinking particularly of files that need to be moved across the LAN.
annew, proud to be a member of KDE forums since 2008-Oct and a KDE user since 2002.
Join us on http://userbase.kde.org |
![]() Registered Member ![]()
|
yea I have the moving the files command down now, but Im getting "bash: /bin/cp: Argument list too long" when trying to move the files to a different directory. Im assuming its b/c I have too many duplicates?
The most important thing I need is a way to move 20,000 files to a new directory. I believe I need a bash script to do this, but I dont know bash scripting language. Before I have to teach myself Bash, is there anyone with Bash skills that could write me a quick bash script to move X number files from /directory1 to /directory2? |
![]() Registered Member ![]()
|
you could try to move the files in batches, based on the filenames.
For example, move all files starting with ab with this command: mv ab* /path/to/new_directory that way, you avoid moving too much files at once..
Riinse, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
yea I tried that. The problem is the file names are erratic, so I could end up with 500 files or 50,000 files if I do it that way. I need a way to control the (number) of files while keeping the file names preserved. I posted a thread in linuxquestions.org for help with a bash script if anyone has any bash scripting skills. http://www.linuxquestions.org/questions/programming-9/ |
![]() Registered Member ![]()
|
okay, so to summorize,
you want to split up a directory with 100,000 files into 5 directories with 20,000 files. The files should stay in order (eg the first 20,000 go to directory1, second 20,000 to directory2, etc) Names should be preserved. i'll ask some local gurus if they can help.
Riinse, proud to be a member of KDE forums since 2008-Oct.
|
![]() Registered Member ![]()
|
thanks! I would really appreciate it, and you seem to have all the relevant points correct. but please make sure to mention I want it split into 2 directories only. so that I have 1 directory of 80,000 files and 1 directory of 20,000 files |
![]() Registered Member ![]()
|
ok well I came up with a small script with some help that seems to do what I need it to do.
My only conundrum is for how to use "mv -n" without it stopping the script once it gets a duplicate. |
![]() Registered Member ![]()
|
Well, i received a script that should do the job.
This script expects the new directories side by side with the original one, like: /home/supreme/original /home/supreme/new-with-20000 /home/supreme/new-with-80000 This is it:
|
Registered users: Bing [Bot], Google [Bot], Sogou [Bot]