LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   How to split a 9 Gig folder in 2x4.5 Gig folders (http://www.linuxquestions.org/questions/slackware-14/how-to-split-a-9-gig-folder-in-2x4-5-gig-folders-352377/)

jayhel 08-11-2005 10:05 PM

How to split a 9 Gig folder in 2x4.5 Gig folders
 
Hi!

I have a 9 Gig folder made up of 5 Meg files (*.mp3 files) and I would like to split it in 2 4.5 Gig folders.
What is the best, most efficient Linux command to achieve this?

Tks,

JL

synaptical 08-11-2005 10:17 PM

umm, mkdir?

:p


not sure what you're asking. "folders" (directories) are usually dynamic and only as big as their contents. do you mean a partition is 9GBs and you want to make two partitions? :confused:

piete 08-12-2005 04:49 AM

It sounds to me like someone is trying to archive an MP3 collection onto DVD ;)

I'm afraid I'd be inclined to do it graphically (I use ROX Filer if you wanted a suggestion for X file browsers). Make 2 subdirectories, then select roughly half the contents of the main directory to go in one, and dump the rest in the other. Then tweak it manually (moving one or two files at a time) to get the right balance. Possibly 30 seconds work?

If you have 1,000 9GB directories and you want to split them all in two, or even, you want to split a directory of arbitrary size into 4.5 GB components then a script is likely the best way of doing it. Off the top of my head, I couldn't give you any specific code (that's not true, actually, but scripting is worth learning yourself ;) ) but my script approach would do something like the following:

1. Make a subdirectory that will, eventually, be 4.5 GB. (mkdir fourfiveDir)
2. Use a loop to accomplish the following: (while ... )
* Check the size of the contents of the 4.5 GB directory. (du fourfiveDir)
* If it's less than 4.5 GB then ...
* Find the next file that will fit in the directory. (another loop through all the files in the main dir)
* mv / cp the file into the directory.
* If the 4.5 GB directory is 4.5 GB OR there are no more files that will fit in it from the main directory, exit the loop.
3. Now make another subdir (mkdir fourfiveDir2) and repeat step 2 ... ad nauseum.

Good luck!
- Piete.

jayhel 08-18-2005 10:12 PM

Split 9 Sig folder in 2x4.5 Gig
 
Thank you Piete.

However, it is not as simple as it seems.

If I split visually the 9 Gig file by doing a cut and paste in KDE,
then...OK,
I get 2x4.5 Gig files.
Yes!
But...
K3B doesn't want to burn these files!
I get the message:
===============================================================
System
-----------------------
K3b Version: 0.12

KDE Version: 3.3.2
QT Version: 3.3.3
Kernel: 2.6.10-1
Devices
-----------------------
MATSHITA UJ-845D D100 (/dev/hdb, ) at /mnt/cdrom [CD-R; CD-RW; CD-ROM; DVD-ROM; DVD-R; DVD-RW; DVD+R; DVD+RW; DVD+R DL] [DVD-ROM; DVD-R Sequential; DVD-RW Restricted Overwrite; DVD-RW Sequential; DVD+RW; DVD+R; DVD+R Double Layer; CD-ROM; CD-R; CD-RW] [SAO; TAO; Restricted Overwrite]

K3b
-----------------------
Size of filesystem calculated: 0

Used versions
-----------------------
mkisofs: 2.1

mkisofs
-----------------------
/usr/bin/mkisofs: Error: '/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,1.mp3' and '/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys, Forrest, Kool & The Gang, Whitney Houston, Madonn
a, Taylor Dayne, Black Box).mp3' have the same Rock Ridge name 'Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,1.mp3'.
/usr/bin/mkisofs: Error: '/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,2.mp3' and '/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys, Forrest, Kool & The Gang, Whitney Houston, Madonn
a, Taylor D.mp3' have the same Rock Ridge name 'Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,2.mp3'.
/usr/bin/mkisofs: Unable to sort directory Shared1
===========================================================

As for the writing of a script is concerned, I don't see how I can test the size of a directory nor increment 1 by 1 the number of files moved to this directory.

Tks,

JL

gbonvehi 08-18-2005 10:49 PM

Re: Split 9 Sig folder in 2x4.5 Gig
 
Quote:

Originally posted by jayhel

/usr/bin/mkisofs:
Error:
'/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,1.mp3'
and
'/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys, Forrest, Kool & The Gang, Whitney Houston, Madonna, Taylor Dayne, Black Box).mp3'
have the same Rock Ridge name
'Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,1.mp3'.

/usr/bin/mkisofs:
Error:
'/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,2.mp3'
and
'/usr/multi/music/Shared1/Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys, Forrest, Kool & The Gang, Whitney Houston, Madonna, Taylor D.mp3'
have the same Rock Ridge name
'Disco - Classic 80's Megamix - (Rick Astley, Pet Shop Boys,2.mp3'.

/usr/bin/mkisofs: Unable to sort directory Shared1

As you can see the names are cut in the ISO, and when those names are cut they both have the same name. Just rename them.

jayhel 08-18-2005 11:36 PM

Split 9 Sig folder in 2x4.5 Gig
 
Thank you Gbonvehi!

I renamed the files: K3B is working now.

JL


All times are GMT -5. The time now is 08:39 PM.