Need script to find the file size of ISO
Need script to find the file size of ISO
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
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
Code: Select all
du -sh /dir/where/Isos/*.iso
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]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]
Code: Select all
du -a /dir/where/Isos/*.iso
[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]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]
How you started? Are you entering everything manually? If you just want to pipe the output into a text file do something like this
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
or
(For an easier to read output in Mb)
Code: Select all
du -a /dir/where/Isos/*.iso | cat > text_file
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
Code: Select all
du -sm /dir/where/Isos/*.iso | cat > textfile
[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]
[url=http://www.murga-linux.com/puppy/viewtopic.php?t=72178][b][i]Puppy Crypt 528[/i][/b][/url]
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.
Copy & Paste it into a text file, and save it (as whatever name you wish)
into one of the following directories:
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:
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:
CatDude
.
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
into one of the following directories:
- /root/my-applications/bin
/usr/bin
/usr/local/bin
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
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.
If you want to keep any of the files created,
copy/move them somewhere else before re-running the script.
CatDude
.
[img]http://www.smokey01.com/CatDude/.temp/sigs/acer-futile.gif[/img]
Actually, was a typo, is s and not a, as i replied quickly...
I'd just do this (cd wherever you need firstly):
Example:
I'd just do this (cd wherever you need firstly):
Code: Select all
find . -iname '*.iso' -exec du -sh {} +
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
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
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
As script:
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:
then did the test:
and the -cropped- results:
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.
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
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
Code: Select all
./ISOs.sh /mnt/data/aqemu/ > ISO_list.txt
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
--------------------------------------------------------------
but though that I should explain what I wrote there as you required it since main post.
Hope it helps.
For reference , there is another command to find file size
For instance to find the file size of the application evince
________________________________________
For instance to find the file size of the application evince
Code: Select all
stat -c %s /usr/bin/evince
- RetroTechGuy
- Posts: 2947
- Joined: Tue 15 Dec 2009, 17:20
- Location: USA
Re: Need script to find the file size of ISO
Wellally 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
Code: Select all
find > listing.txt
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
(this was "md5deep -rz my-applications > listing.txt")
You can find it here (you want the i386 version):116 214b0f81adc3cae58acc3e5659153b23 /root/my-applications/Sample vid script.txt
185 5808e3562d0eb399a2bbbfeecc15832f /root/my-applications/lib/README-my-applications-lib.txt
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]
[url=http://wellminded.net63.net/]WellMinded Search[/url]
[url=http://puppylinux.us/psearch.html]PuppyLinux.US Search[/url]