Need script to find the file size of ISO

Booting, installing, newbie
Post Reply
Message
Author
User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

Need script to find the file size of ISO

#1 Post by ally »

hey guys

I have collected puppy ISOs for a while now, recently a call was made for kernel version info so I opened the ISO and got the data from vmlinuz

I had to do this manually as I couldn't understand the script that somebody posted

I had started recorded file sizes on some but not all so thought that somebody could help by generating a script to output ISO name and file size for all ISOs in a directory but also explain how and why it works

if anybody could take up the baton I would be sincerely grateful

cheers

:)

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#2 Post by GustavoYz »

Code: Select all

du -sh /dir/where/Isos/*.iso
Something like this?

DPUP5520
Posts: 800
Joined: Wed 16 Feb 2011, 05:38

#3 Post by DPUP5520 »

Code: Select all

du -ah /dir/where/Isos/*.iso


would be the proper code I believe as the -sh switches would only output a total size of the ISO files and -ah would list them seperately

Edit: Only checks current directory and is not recursive
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69651][b][i]PupRescue 2.5[/i][/b][/url]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#4 Post by ally »

thanks both

over 1600 files so will output to txt file as only small amount ends in terminal

how to obtain output in bytes?

:)

DPUP5520
Posts: 800
Joined: Wed 16 Feb 2011, 05:38

#5 Post by DPUP5520 »

Code: Select all

du -a /dir/where/Isos/*.iso
This will put the output in bytes but why the hell would u want that?
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69651][b][i]PupRescue 2.5[/i][/b][/url]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#6 Post by ally »

that's how I started!

:)

DPUP5520
Posts: 800
Joined: Wed 16 Feb 2011, 05:38

#7 Post by DPUP5520 »

How you started? Are you entering everything manually? If you just want to pipe the output into a text file do something like this

Code: Select all

du -a /dir/where/Isos/*.iso | cat > text_file
This will create a file and pipe the output of du to it

Edit: If you are pulling everything from a single directory I think GustavoYz had the better idea using the s switch as long as you are specifying a file type and using * as it will only list the files and not the entire directory like the a switch does so if you have all the ISO files in a single directory and want a list of how big all of them are you could do

Code: Select all

du -sb /dir/where/Isos/*.iso | cat > textfile
or

Code: Select all

du -sm /dir/where/Isos/*.iso | cat > textfile
(For an easier to read output in Mb)
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=69651][b][i]PupRescue 2.5[/i][/b][/url]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]

User avatar
CatDude
Posts: 1563
Joined: Wed 03 Jan 2007, 17:49
Location: UK

#8 Post by CatDude »

Hello ally

Here is a little script i knocked together (i'm sure it could be improved)
which will recurse through all subdirectories inside of the directory from which the script is run from.

Code: Select all

#!/bin/sh
#
# Clean up previous temp files
rm /tmp/iso-paths
rm /tmp/sizes-fullpaths
rm /tmp/iso-sizes
rm /tmp/iso-names
rm /tmp/iso-sizes_iso-names

sleep 0.5
#Find all ISO's, and redirect output to a temporary file.
find $PWD -name "*.iso" -type f > /tmp/iso-paths

# Now get the file sizes, redirecting output to another temporary file.
for iso in $(cat /tmp/iso-paths) ; do
du -a $iso  >> /tmp/sizes-fullpaths
done

# Split content into two files. (removing the PATH from the second one)
cat /tmp/sizes-fullpaths | awk '{print $1}' > /tmp/iso-sizes
cat /tmp/sizes-fullpaths | awk '{print $2}' | sed 's/^.*\///' > /tmp/iso-names

# Combine the two files back into one.
paste /tmp/iso-sizes /tmp/iso-names >> /tmp/iso-sizes_iso-names

Copy & Paste it into a text file, and save it (as whatever name you wish)
into one of the following directories:
  • /root/my-applications/bin
    /usr/bin
    /usr/local/bin
Make sure it is executable.

I have my ISO images saved in a setup similar to this:

/mnt/sda12/ISOs/
/mnt/sda12/ISOs/Fatdog
/mnt/sda12/ISOs/Legacy
/mnt/sda12/ISOs/LHP
/mnt/sda12/ISOs/Lupu
/mnt/sda12/ISOs/Precise
/mnt/sda12/ISOs/Racy
/mnt/sda12/ISOs/Slacko
/mnt/sda12/ISOs/Wary


So i open a console/terminal in /mnt/sda12/ISOs/
and then run the script from there.
(Simply type the name you gave your script.)

When the script has finished running it will return to the prompt,
and you will find the output in this file: /tmp/iso-sizes_iso-names
which will have content similar to this:

Code: Select all

142676	wheezy-3.5.2.2-SCSI.iso
130908	lupu-525.iso
129780	lupu-520.iso
141444	wary-5.3.92.iso
126036	wary-511-k2.6.32.28.iso
161656	wary-511-k2.6.32.28_MediaPlayers.iso
If you would rather have the full PATHS to the ISO's included,
then have a look at this file: /tmp/sizes-fullpaths
which will have content similar to this:

Code: Select all

142676	/mnt/sda12/ISOs/DpupWheezy3522/wheezy-3.5.2.2-SCSI.iso
130908	/mnt/sda12/ISOs/lupu-525.iso
129780	/mnt/sda12/ISOs/lupu-520.iso
141444	/mnt/sda12/ISOs/Wary/5.4beta2/wary-5.3.92.iso
126036	/mnt/sda12/ISOs/Wary/wary-511-k2.6.32.28.iso
161656	/mnt/sda12/ISOs/Wary/wary-511-k2.6.32.28_MediaPlayers.iso
  • NOTE:
    The first time you run the script it will complain about not being able to remove the temp files,
    do not worry about it as they do not yet exist. :wink:

    If you want to keep any of the files created,
    copy/move them somewhere else before re-running the script.
Hope this helps
CatDude
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#9 Post by GustavoYz »

Actually, was a typo, is s and not a, as i replied quickly...
I'd just do this (cd wherever you need firstly):

Code: Select all

find . -iname '*.iso' -exec du -sh {} +
Example:

Code: Select all

find . -iname '*.iso' -exec du -sh {} + | sort -h
12M     ./lil/TinyCore-current.iso
34M     ./lil/pUPnGO_V412_060113.iso
46M     ./lil/beini-1.2.3.iso
94M     ./0linux-mini-04112012-x86_64.iso

User avatar
Flash
Official Dog Handler
Posts: 13071
Joined: Wed 04 May 2005, 16:04
Location: Arizona USA

#10 Post by Flash »

No doubt I'm showing off my ignorance to mention this, but if you open a directory in ROX and change to the "Show extra details" view, the size of all the files in that directory is shown.

User avatar
Semme
Posts: 8399
Joined: Sun 07 Aug 2011, 20:07
Location: World_Hub

#11 Post by Semme »

Flash- you're a :D Guinness!

Then again..
.. generating a script to output ISO name and file size for all ISOs in a directory but also explain how and why it works.

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#12 Post by ally »

hey all

thanks for the input

@flash - I wanted to get away from doing things manually, I've 1600+ puppies now and it takes ages! also wanted a practical script example to try and play with

unfortunately I suffer with mental health issues amongst other things and information and learning is becoming much harder for me than it used to. although I have tried script tutorials I've struggled and thought a useful practical example would help spur me on

thanks again everybody for the input

:)

User avatar
GustavoYz
Posts: 883
Joined: Wed 07 Jul 2010, 05:11
Location: .ar

#13 Post by GustavoYz »

As script:

Code: Select all

#!/bin/bash
######################################################################
# List all ISO under dir showing sizes in human readable format.
######################################################################
[ $1 ] && DIR_SEARCH="$1"

cd $DIR_SEARCH &&
echo -------------------------------------------------------------- &&
find . -iname '*.iso' -exec du -sh {} + | sort -h
echo -------------------------------------------------------------- &&
exit 0
The script looks for an argument to be used as path of the main search with find
and changes directory to it.

"find" will search in that directory and subdirs for files whose names ends with '.iso':
the * is called "wildcard" and means "something", so it will search for "something.iso".
Is 'iname' and not 'name' because we don't mind much if is on caps or not, we want
case insensitive search (so can match files called SOMETHING.ISO" too).

For each result, find will create a command for launch, which is 'du -sh filename.iso' and will exec it.

All the output above is piped and goes to "sort"; this is only for readibility and is not essential.
The idea is sort all the iso files by size in the final list, from minor to major so can have
a criteria for read and seek in the list later.

Make it a file and run it piped to a new txt if you want to keep the list of isos.
I did it and called "ISOs.sh" and changed permissions like this:

Code: Select all

chmod +x ISOs.sh
then did the test:

Code: Select all

./ISOs.sh /mnt/data/aqemu/ > ISO_list.txt
and the -cropped- results:

Code: Select all

--------------------------------------------------------------
12M     ./TinyCore-current.iso
34M     ./pUPnGO_V412_060113.iso
46M     ./beini-1.2.3.iso
94M     ./0linux-mini-04112012-x86_64.iso
106M    ./4MLinux-4.1-allinone-edition.iso
106M    ./PuppyArcade_9.iso
112M    ./qrky-120.iso
116M    ./slacko-5.3.3-4g-SCSI.iso
120M    ./Feather-0.7.5.iso
...
2,2G    ./TEXLIVE2012/ISO_TEXLIVE_2012/texlive2012-20120701.iso
--------------------------------------------------------------
The script itself is very silly (after all is just some "find" procedure),
but though that I should explain what I wrote there as you required it since main post.

Hope it helps.

User avatar
don570
Posts: 5528
Joined: Wed 10 Mar 2010, 19:58
Location: Ontario

#14 Post by don570 »

For reference , there is another command to find file size

For instance to find the file size of the application evince

Code: Select all

stat -c %s /usr/bin/evince
________________________________________

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#15 Post by ally »

thanks again for all the inputs

much appreciated

:lol: :)

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#16 Post by Ted Dog »

Gee, and I thought I was a distro-junkie... :lol:

Distrowatch is my dealer, I'm trying to cut back...

Nice set of tools, keep them coming, would be nice to sort by date so a older version of same name is pushed down the list.

User avatar
ally
Posts: 1957
Joined: Sat 19 May 2012, 19:29
Location: lincoln, uk
Contact:

#17 Post by ally »

hey TD

I had to increase my broadband package, I'm currently at 1648 but catdude has maybe 80 or so that I've been unable to locate from the web

it is my hope to one day be able to host them all but illness has prevented my plans to date

:)

User avatar
Ted Dog
Posts: 3965
Joined: Wed 14 Sep 2005, 02:35
Location: Heart of Texas

#18 Post by Ted Dog »

I need to find the backups of puptrix.org to fill in what you do not have. I took on the task of puppylinux spin-off control and reporting but it quickly became overhelming task, since so many people wrote so many wonderful stuff with puppy.

User avatar
RetroTechGuy
Posts: 2947
Joined: Tue 15 Dec 2009, 17:20
Location: USA

Re: Need script to find the file size of ISO

#19 Post by RetroTechGuy »

ally wrote:hey guys

I have collected puppy ISOs for a while now, recently a call was made for kernel version info so I opened the ISO and got the data from vmlinuz

I had to do this manually as I couldn't understand the script that somebody posted

I had started recorded file sizes on some but not all so thought that somebody could help by generating a script to output ISO name and file size for all ISOs in a directory but also explain how and why it works

if anybody could take up the baton I would be sincerely grateful

cheers

:)
Well

Code: Select all

find > listing.txt
Would find all the file names. Some work could "ls" them each.

But perhaps you would like an md5 to go with the filename and size.

then (you will have to add md5deep to your toolset)

Code: Select all

md5deep -rz > listing.txt
will create something like this:

(this was "md5deep -rz my-applications > listing.txt")
116 214b0f81adc3cae58acc3e5659153b23 /root/my-applications/Sample vid script.txt
185 5808e3562d0eb399a2bbbfeecc15832f /root/my-applications/lib/README-my-applications-lib.txt
You can find it here (you want the i386 version):
http://packages.debian.org/squeeze/md5deep
[url=http://murga-linux.com/puppy/viewtopic.php?t=58615]Add swapfile[/url]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]

Post Reply