Is there a script or small tool


Results 1 to 11 of 11

Thread: Is there a script or small tool

  1. #1
    Join Date
    Sep 1999
    Location
    Santa Cruz, CA, USA
    Posts
    1,213

    Is there a script or small tool

    available for Windows systems that will tell me what file types there are and what their size is? Okay let me clarify this, I have a friends Windows XP laptop that I am trying to clean up and fix. And I have several issues with it... but first I am trying to figure out where the heck all their drive space went!

    They have an 80GB hard drive and it's 4GB below capacity. They don't think they have that many files and suspect a virus. Now the system has been showing erractic behavior but I think it's because it's the drive is so close to being maxed out. Now this is a laptop as well, just so you know.

    So what I am wondering is a simple script that I can load and run that will tell me something like this:

    *.jpg files found = 200,000 files, total size = 20GB
    *.mpg files found = 156 files, total size = 1.5GB

    And so on. Once I have that figured out then I will post the other problem I am having!
    One by one the penguins steal my sanity...

    Vanpooling now...

  2. #2
    Join Date
    Oct 2006
    Location
    Scotland
    Posts
    16
    I don't know of a script or small tool but you could boot with a Knoppix live-cd disk and within it do a search (find file) for *.jpeg etc

  3. #3
    Join Date
    Jan 2003
    Location
    London, England
    Posts
    320
    the du utility might be off help. off the top of my head, you could do something like this:

    du -csh *

    look at the options in the man page... works on cygwin as well, so you can do it on that win machine you mentioned. hope this helps.

    tuco

  4. #4
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,984
    I am taking the risk of being labelled as the laziest and the most stupid member in the forum with the suggestion below.

    Hook up a spare empty USB device large enough to hold either the .jpg or .img files. mount the USB drive. Say it is recognised as a h:\ drive in Windows. Go to the command prompt and type
    Code:
    xcopy c:\ *.jpg  h:\ /s
    When finish just right click the h drive and find the size from the "properties". It should contain all the *.jpg files. Tried it on my e:\ drive and the 223 .exe files ending up 57.7Mb in a spare pen drive.

    Quick format h:\ and repeat with *.img
    Last edited by saikee; 08-08-2007 at 09:45 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  5. #5
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,984
    Trying to redeem some respect here. So for the first time in my life I had to write a couple of Python scripts, trying to show my laziness can be brought under control. Unlike the lazy method, which is done in Windows, in Post #4 the following method is 100% Linux.

    I tackled the problem in 4 stages

    (1) Use bash terminal command "find" to get all *.jpg of a mount partition and dump the output onto a file call "alljpg" which hold the raw data of the *.jpg files names only.
    Code:
     find /abit/2007-7/Sam\ backup/Home\ backup/WattArch/Digital_Pictures/ -name *.jpg > alljpg
    (2) Run a Python script "alljpg.py" to read the file alljpg, created by Item (1) above as the input file. Add sub-string "ls -l" in front and ">> 3rd" at the end of each line. The first line has one ">" less to initial the output file. The output is dumped onto a file called "next". I use "next" as a Bash script to list each file with the file size displayed.

    Python Script alljpg.py is listed below
    Code:
    f=file('alljpg', 'r')
    out=file('next','w')
    i=0
    for line in f:
            i=i+1
    	y=line.replace(" ","\ ")
            if i==1 :
    		y="ls -l "+y.rstrip()+" >3rd\n"
    	else:
    		y="ls -l "+y.rstrip()+" >>3rd\n"
    	print y
    	out.write(y)
    print "total no. of *.jpg = ",i
    I use a lot of spaces in my subdirectory system and have to change every occurrance of " " with "\ " in order to get the command "ls" responds to it. To run a Python script alljpg.py the command is just
    Code:
    python alljpg.py
    (3) Execute Bash script "next" after altering its property
    Code:
    chmod 755 next
    /bin/bash next
    A typical line from "next" looks like this
    Code:
    ls -l /abit/2007-7/Sam\ backup/Home_backup/WattArch/Digital_Pictures/PhotoDisk2004/2004\ Mar\ Wall\ Mui\ came\ home/p3200475.mov >>3rd
    This will list each *.mov (I did both *.jpg and then *.mov) file in details with the file size displayed in the 5th field like this in the last output file called "3rd" (truncated below)
    Code:
    -rwxrwxrwx 1 root root 29546056 2004-12-29 10:38 /abit/2007-7/Sam backup/Home_backup/WattArch/Digital_Pictures/Skiing/2005-1-Bourg/D6 La Rosiere/pc290057.mov
    -rwxrwxrwx 1 root root 13044332 2004-12-29 15:25 /abit/2007-7/Sam backup/Home_backup/WattArch/Digital_Pictures/Skiing/2005-1-Bourg/D6 La Rosiere/pc290063.mov
    -rwxrwxrwx 1 root root 14189836 2004-12-29 15:18 /abit/2007-7/Sam backup/Home_backup/WattArch/Digital_Pictures/Skiing/2005-1-Bourg/D6 La Rosiere/pc290062.mov
    -rwxrwxrwx 1 root root 8658640 2004-12-29 12:03 /abit/2007-7/Sam backup/Home_backup/WattArch/Digital_Pictures/Skiing/2005-1-Bourg/D6 La Rosiere/pc290060.mov
    (4) Use a Python script sam11.py to extract the file size column and add them together. The sam11.py looks like this
    Code:
     f=open('3rd', 'r')
    i=0
    sum=0
    for line in f:
       	i=i+1     
    	lst=line.split()
    	y=lst[4]
    	#print i,int(y),sum
    	sum=sum+int(y)
    print "total no. of files = ",i,"total storage (Mb) = ",sum/1000000.
    Tried it on my box and seems to be OK for extracting *.jpg and *.mov files out.
    Last edited by saikee; 08-09-2007 at 06:17 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  6. #6
    Join Date
    Sep 1999
    Location
    Santa Cruz, CA, USA
    Posts
    1,213
    Cool saikee, I'll give that a try!
    One by one the penguins steal my sanity...

    Vanpooling now...

  7. #7
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,984
    You can just copy the two Python scripts and put the above 4 operations into one Bash script say justlinux1 listed below
    Code:
    find /abit/2007-7/Sam\ backup/Home_backup/WattArch/Digital_Pictures/ -name *.jpg > alljpg
    python alljpg.py
    /bin/bash next
    python sam11.py
    Make it executable by
    Code:
    chmod 775 justlinux1
    and run it with just one command
    Code:
    /bin/bash justlinux1
    Just adjust the directory and the file name you want to suit your case in the red and blue bits above. Don't think I can make it any lazier.

    If you have not used Python before don't worry. Me too. I started it because thinking it is a simple application in this thread and so I may be able to learn it. Python is shipped with many distros. Thus you can do everything with a Linux Live CD. Think you need to do a "chmod 775" with the two Python scripts before they are executable.

    You can download Python for Windows too but I don't know a Windows command that give a similar search like the "find" command in Linux.
    Last edited by saikee; 08-09-2007 at 06:20 AM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  8. #8
    Join Date
    Jan 2004
    Location
    boston, mass USA
    Posts
    1,880
    TreesizePro for Windows

  9. #9
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,984
    I know back in win9x days there were some utilities that display all files with the same extension in the whole hard disk. Don't know how good TreesizePro for Windows is but one has to pay if the software is used beyond 21 days. Obviously it won't work for Linux.

    I finally go the about 4 operations programmed into a Python script which can be executed by terminal command (no root user needed)
    Code:
    python justlinux1.py
    The content of justlinux1.py is as follow
    Code:
    saikee@saikee-desktop:~$ cat justlinux1.py
    import os
    os.system('find /abit/2007-7/Sam\ backup/Home_backup/WattArch -name *.jpg > alljpg')
    os.system('find /abit/2007-7/Sam\ backup/Home_backup/WattArch -name *.JPG >> alljpg')
    f=file('alljpg', 'r')
    out=file('next','w')
    i=0
    for line in f:
            i=i+1
            y='"'+line.rstrip()+'"'
            if i==1 :
                    y="ls -l "+y+" >3rd\n"
            else:
                    y="ls -l "+y+" >>3rd\n"
            print y
            out.write(y)
    print "total no. of *.jpg = ",i
    f.close()
    out.close()
    os.system('/bin/bash next')
    f=open('3rd', 'r')
    i=0
    sum=0
    for line in f:
            i=i+1     
            lst=line.split()
            y=lst[4]
            print i,int(y),sum
            sum=sum+int(y)
    print "total no. of files = ",i,"total storage (Mb) = ",sum/1000000.
    f.close()
    saikee@saikee-desktop:~$
    I quite enjoy learning Python to carry out this task. Paying for a software destroys the fun. The script can do both Windows and Linux too. It takes seconds to expand it to cover more than one disk.

    Sorry for changing idea between Post #4, #5, #7 and now #9. The truth is I am not related to IT and have bugger off to nothing programming experience. I just used the opportunity to learn Python.
    Last edited by saikee; 08-09-2007 at 09:04 PM.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

  10. #10
    Join Date
    May 2004
    Location
    Arizona
    Posts
    76
    If you boot the system with a linux live disk and mount the windows drive under /mnt/sda1 you should be able to enter the following at the command line to find total size of all .jpg files on the windows drive. You can change the extension you are looking for by changing "*.jpg" to suit. You can change /mnt/sda1 to suit your local mountpoint.

    Code:
    total=0; for i in `find /mnt/sda1 -name "*.jpg"  -ls |awk '{ print $7 }'`; do total=$(($total + $i)); done; echo "$(($total/1024))k"
    n00b

  11. #11
    Join Date
    Jun 2004
    Location
    Newcastle upon Tyne
    Posts
    2,984
    Bryon Speede

    Your script is spot on. Much faster to give the same result.
    Linux user started Jun 2004 - No. 361921
    Using a Linux live CD to clone XP
    To install Linux and keep Windows MBR untouched
    Adding extra Linux & Doing it in a lazy way
    A Grub menu booting 100+ systems & A "Howto" to install and boot 145 systems
    Just cloning tips Just booting tips A collection of booting tips

    Judge asked Linux "You are being charged murdering Windoze by stabbing its heart with a weapon, what was it?" Replied Linux "A Live CD"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •