LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-03-2022, 11:29 AM   #1
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Rep: Reputation: 61
Talking Does a command, or a combination of commands exist that would move a bunch of files into a new directory and once that directory is full ...


Hey LQ,

So basically I've got a directory with like 30k .gz files in it. These are back up files.

I want to burn these to DISC media. What I normally do is browse the directory, keep selecting archive files until the file manager reports to me that I am nearing 4.5GB, then I CUT them, create a directory and name the directory with two dates, the first date is the date of the oldest archive I currently have CUT, the second date is the date of the newest archive I have CUT.

Naming of the directories is simple for me to do, I don't mind doing that manually, but is there a command that would do this cutting and creation of directories for me once I specify how big I want the directories to be?

I presume this is more in the realm of shell scripting rather than piping and chaining up commands together. I am prepared to do this as well if need be, but I recently learned about zgrep and was surprised someone had built a utility just for that purpose, so I figured I'd inquire.

Any tips in the right direction greatly appreciated as usual.

Cheers all.
 
Old 08-03-2022, 11:52 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,876

Rep: Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315Reputation: 7315
even tar can split the created tar file into pieces.
Otherwise you can use du (for example) to check the size of a directory.
 
Old 08-03-2022, 04:56 PM   #3
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
https://github.com/jgoerzen/datapacker/wiki
 
2 members found this post helpful.
Old 08-04-2022, 06:02 AM   #4
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369
Blog Entries: 1

Rep: Reputation: 49
Wink

Quote:
Originally Posted by !!! View Post
Great find!
 
Old 08-04-2022, 07:56 AM   #5
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,605

Rep: Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548

I don't think datapacker can be helpful here - it doesn't have any date functionality, and appears to consider file size not disk usage, which matters when you're aggregating files to burn to DVD.

Wouldn't surprise me if a proper tool existed, but also wouldn't surprise me if most people just use a script.

Possibly start with something like:
Code:
find . -type f -print0 | du --block-size=2K --time --files0-from=- | sort -k2
This outputs a list of filenames (no directories) with their disk usage and last modified time (which the sort orders by), and this can then be looped through in Awk or Bash, summing and compiling the filenames until the threshold, logging the end/start dates, then repeating until all files are batched, which I'd then review before performing the operation.

When dealing with cases like this I often don't do file modification directly - instead I'll generate a script that does it, so I can manually review it before running - in case any oddities stick out. (An example in the above would be if there are any filenames with newlines in; the first half will deal with them, but the second half needs additional params if they are a possibility; such a situation can/should be guarded against in the script, but if that were overlooked, may manifest itself in an command that looks odd.)

 
1 members found this post helpful.
Old 08-04-2022, 08:01 AM   #6
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,605

Rep: Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548

On a separate note, title of this thread is not a good one: titles should be a concise description of what a thread is about.

The first half of this thread's title does not contribute anything to that description, but readers don't know that until they've got a dozen words in - some will have given up by then.

Like a ladder, it is best when they are long enough to get from one place to another, but not so long that it takes a prolonged crawl to get there.

 
1 members found this post helpful.
Old 08-04-2022, 08:22 AM   #7
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369
Blog Entries: 1

Rep: Reputation: 49
Simplification is complicated
 
Old 08-04-2022, 10:16 AM   #8
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
Quote:
Originally Posted by boughtonp View Post
On a separate note, title of this thread is not a good one: titles should be a concise description of what a thread is about.

The first half of this thread's title does not contribute anything to that description, but readers don't know that until they've got a dozen words in - some will have given up by then.

Like a ladder, it is best when they are long enough to get from one place to another, but not so long that it takes a prolonged crawl to get there.
That's as many characters as the title field would let me put in there. Now that you've read the post, what would you have titled it as?
 
Old 08-04-2022, 10:38 AM   #9
ychaouche
Member
 
Registered: Mar 2017
Distribution: Mint, Debian, Q4OS, Mageia, KDE Neon
Posts: 369
Blog Entries: 1

Rep: Reputation: 49
Cool

Quote:
Originally Posted by wh33t View Post
That's as many characters as the title field would let me put in there. Now that you've read the post, what would you have titled it as?
title 1 : How to efficiently burn lots of files into multiple DVDs
title 2 : How to move files to directories based on their total disk size

Again, it's complicated to simplify...
 
1 members found this post helpful.
Old 08-04-2022, 11:39 AM   #10
!!!
Member
 
Registered: Jan 2017
Location: Fremont, CA, USA
Distribution: Trying any&ALL on old/minimal
Posts: 997

Rep: Reputation: 382Reputation: 382Reputation: 382Reputation: 382
Quote:
Naming of the directories is simple for me to do, I don't mind doing that manually
'Read before rant' maybe the solution here
 
Old 08-04-2022, 12:15 PM   #11
wh33t
Member
 
Registered: Oct 2003
Location: Canada
Posts: 922

Original Poster
Rep: Reputation: 61
Thanks for all the responses. I ended up writing a PHP script to do it all for me (I know PHP, don't know Bash at all haha).

Cheers.
 
Old 08-04-2022, 04:52 PM   #12
boughtonp
Senior Member
 
Registered: Feb 2007
Location: UK
Distribution: Debian
Posts: 3,605

Rep: Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548Reputation: 2548
Quote:
Originally Posted by wh33t View Post
That's as many characters as the title field would let me put in there.
That's ... not surprising. You should have taken that as a hint!

Again, titles should be concise, direct, succinct - not verbose.


Quote:
Now that you've read the post, what would you have titled it as?
As I already said, the entire first half of it is redundant - everything upto and including the word "would" could be removed and it would improve the title, but even that second part could use half the words and still convey the same detail: "move files into directories until full".

An even better one would communicate the overall problem, e.g. "batching files into DVD-sized groups".

 
1 members found this post helpful.
Old 08-04-2022, 07:55 PM   #13
computersavvy
Senior Member
 
Registered: Aug 2016
Posts: 3,345

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by wh33t View Post
Thanks for all the responses. I ended up writing a PHP script to do it all for me (I know PHP, don't know Bash at all haha).

Cheers.
Perfect opportunity for you to begin learning bash.

Bash is after all the commonly used shell and everything you do on the command line (including launching php & probably writing your php script) begins with using bash.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
have a bunch of letter character else when pressing Alt key + a (bunch) letter BudiKusasi Linux - Software 1 12-07-2021 04:30 AM
cat command - for every combination of 6 files, merge into a single image file. Numptius Linux - Newbie 13 06-28-2018 02:40 AM
Bind Mouse Button Combination to Keyboard Key Combination? neoAKiRAz Linux - Desktop 0 05-04-2007 12:49 PM
un-TARring a bunch of files at once grapnell Linux - General 2 02-12-2006 09:18 AM
un-TARring a bunch of files at once grapnell Linux - Software 4 02-12-2006 09:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration