Getting large file sizes in AppleScript...

For starters I am new to AppleScript. Please excuse my lack of knowledge.
I am trying to get file sizes for large files and kicking that out to a text file. Problem is that all these files are a gigabyte and up. When I use:
set fileSIZE to size of (info for chosenFile) as string
--result is 1.709683486E+9
I also tried using:
tell application "Finder"
set theSize to physical size of chosenFile
end tell
--result is 1.724383232E+9
So, my question is there another way that shows me the bytes in this format "1,709,683,486" bytes.
The "size of (info for chosenFile)" shows the right numbers "1.709683486". I don't really need the commas. I had a larger file of 44GB and the result was 4.4380597717E+10.
How do I remove the ".", the "E+9" or "E+10"?

looks like hubionmac has found a winner.
perhaps not:
page 89 applescript language guide:
the largest integer value is 536,870,911. Larger integers are convert to real numbers.
Notice the different request for size report different values.
Notice that ls -l return the data fork size in Tiger.
Notice the clever way of working with the resource fork in unix ( /rsrc ). I found this in juliejuliejulie's code in another post.
set theFile to (choose file)
set fileSIZE to size of (info for theFile) as miles as string
log "fileSIZE = " & fileSIZE
tell application "Finder"
   set pSize to physical size of theFile
end tell
log "pSize = " & pSize
set stringSize to pSize as miles as string
log "stringSize = " & stringSize
set theItem to quoted form of POSIX path of (theFile)
log "theItem = " & theItem
-- unix ls -l command will give size. 
-- Looks like ls -l gives the data fork size.
set theDataSize to (do shell script "ls -l " & theItem & " | awk '{print $5}'")
log "theDataSize = " & theDataSize
set theRsrc to (POSIX path of theFile) & "/rsrc"
log "theRsrc = " & theRsrc
set theRsrc to quoted form of theRsrc
log "theRsrc = " & theRsrc
set theRsrcSize to (do shell script "ls -l " & theRsrc & " | awk '{print $5}'")
log "theRsrcSize = " & theRsrcSize
set output to do shell script "echo \"" & theDataSize & "+" & theRsrcSize & "\" | bc "
log "combined data and resource size = " & output
Here is what I get when I run the above script.
tell current application
   choose file
      alias "Macintosh-HD:System Folder:Finder"
   info for alias "Macintosh-HD:System Folder:Finder"
      {name:"Finder", creation date:date "Tuesday, May 29, 2001 3:00:00 PM", modification date:date "Tuesday, May 29, 2001 3:00:00 PM", icon position:{1, 128}, size:2.439365E+6, folder:false, alias:false, package folder:false, visible:true, extension hidden:false, name extension:missing value, displayed name:"Finder", default application:alias "Macintosh-HD:Applications (Mac OS 9):Utilities:Assistants:Setup Assistant:Setup Assistant", kind:"Finder", file type:"FNDR", file creator:"MACS", type identifier:"dyn.agk8yqxwenk", locked:false, busy status:false, short version:"9.2", long version:"9.2, Copyright Apple Computer, Inc. 1983-2001"}
   (*fileSIZE = 2439365*)
end tell
tell application "Finder"
   get physical size of alias "Macintosh-HD:System Folder:Finder"
      2.445312E+6
   (*pSize = 2.445312E+6*)
   (*stringSize = 2445312*)
   (*theItem = '/System Folder/Finder'*)
end tell
tell current application
   do shell script "ls -l '/System Folder/Finder' | awk '{print $5}'"
      "1914636"
   (*theDataSize = 1914636*)
   (*theRsrc = /System Folder/Finder/rsrc*)
   (*theRsrc = '/System Folder/Finder/rsrc'*)
   do shell script "ls -l '/System Folder/Finder/rsrc' | awk '{print $5}'"
      "524729"
   (*theRsrcSize = 524729*)
   do shell script "echo \"1914636+524729\" | bc "
      "2439365"
   (*combined data and resource size = 2439365*)
end tell
Message was edited by: rccharles

Similar Messages

  • Need to get large file sizes down to downloadable sizes-how?

    I am using Compressor 4 and have several professional videos I produced with Final Cut Studio in QuickTime/.MOV format using ProRes 442. They are all 720p and of course, all have large file sizes. I needed to convert them so they are compatible with iTunes as well as Apple devices (AppleTV, iPad/iPod/iPhone, etc). They also need to be downloadable in a reasonable time and I of course want to maintain a quality image. Several of the videos are about an hour long, some a little more.
    I an unable to get most of these files to be small enough for practical download and still maintain an acceptable quality. For example:
    I have one video (QuickTime rendered from FCPS) that runs 54 minutes. 1280x720, ProRess 422, Linear PCM with a Bit rate of 72.662. The best I seem to be able to get out of compressor is to use the setting options for "HD for Apple Devices (5 Mbs)" which gives me a file that's just over 2Gb. Not bad, and the quality is still very good, but the file size is just too big for people to download. I get reports of people getting estimates of 77 hours to download this one file.
    I did try using the setting under Video Sharing Services / Large 540p Video Sharing just to see what it would give me, but it really wasn't that much smaller and the quality was noticeably degraded.
    I'm confused as to what to do about this. I have downloaded things from iTunes before that are good quality, about an hour and their file sizes are simply bnot this big.
    Can anyone give me some advice? Thank you. Grateful for anything you can offer.
    MC

    If you're not concerned with precise average bitrate, use h.264 codec, set bitrate to "automatic" and use the quality slider. Be sure to have "keyframes" on "automatic"; every 24 frames or so makes h.264 quite inefficient and is only useful for live-streaming, where you want people to be able to resynchronise as quickly as possible. Having multi-pass enabled might help, but I'm not sure what it does when using constant-quality encoding.
    Do a test-encoding of a representative clip of maybe about rwo minutes or so, play with the quality slider and see how far down you can go and still be satisfied with the quality. Using "automatic" bitrate uses as many bits to encode each frame as is necessary to get the required quality, and file sizes will vary depending on the type of material. Complex textures and high motion will use more bits, still frames and slow pans will use very little.
    A light chroma-channel denoising may help improve perceived quality, as may very light sharpening in case you scaled down the material.
    If you're still not happy with the bitrate vs. quality tradeoff, try reducing the resolution, but generally you should get 720p down to around 2.5 to 3.0 Mbps with adequate quality.
    On the other hand, If someone needs 77 hours to download 2 GB, they have another problem anyway. That sounds like a 56k modem connection. What's he doing trying to download HD content anyway?
    Bernd

  • Large file sizes

    Hello,
    Does anyone else think that keynote audio presentation are a bit on the large size when exported as flash? Here is an example;
    Keynote '08 five minute presentation with narration = 8MB
    Adobe Breeze twenty minute presentation with narration = 10MB
    (both are almost the same resolution)
    Both had similar content, but the keynote ones are coming out so large that any one with a regular speed connection will have to start downloading them and then go make a coffee. Any suggestions or comment about getting your file sizes down are welcome.

    you can use any swf size you like. you can use google to
    search for broadband penetration statistics to see what percentage
    of visitors will have an unsatisfactory experience trying to enter
    your website.

  • Video Stalls - Larger File Size

    Just downloaded Battlestar Galactica season 2 and the video stalls at full screen. Do not have this problem with previous Battlestar Galactica shows and movies that I have downloaded in the past.
    I notice the File Size and Total Bit Rate of the new shows are three times greater in size than the shows I've downloaded in the past.
    Using the utility ativity monitor, I notice I'm maxing out my CPU when I go to full screen which I think is causing my video stall.
    I also notice that now my previous TV show downloads don't fully fill my screen like that did before the new downloads.
    I hope someone might know how I can get my TV shows back to working normal at full screen and why the new TV shows file sizes are larger than before.
    Thanks for Your Help
    Ricky
    PowerBook G4 15" LCD 1.67GHz   Mac OS X (10.3.9)  

    Thanks for the reply. Shortly after I posted, I started to relize that Apple was offering better TV Show quality which results in larger file sizes. I also went to my Energy Saver section in System Prefrences and found my Optimize Energy Settings was set for Presentations. I changed it to Highest Performance which resolved the issue.
    iTunes 7.0.2
    Quicktime 7.1.3
    RAM 512MB
    Thanks for your help.

  • Saving jpeg and png files large file size

    Ive recently purchased web premium 5.5 and Im trying to save files in jpeg and png format in Photoshop and Im getting unexpectedly large file sizes, for example I save a simple logo image 246x48 which consists of only 3 basic colours and when I save it as a jpeg quality 11 it reports the file size in the finder as 61.6k, I save it as a png file and its 60.2k also I cropped the image to 190x48 and saved it as a png and the file size is actually larger at 61.9k saving as a jpeg at quality 7 the files size is a still relatively large 54k.
    I have a similar png non indexed colour logo on my mac I saved in CS3 on a pc which is actually larger at 260x148 and it's only 17k and that logo is actually more complex with a gloss effect over part of it. Whats going on and how do I fix it, It's making Photoshop useless especially when saving for the web
    Thanks

    Thanks I had considered that but all my old files are reporting the correct files sizes I have been experimenting and fireworks saves the file at png 24 at 2.6k and jpegs at 5.1k, but I don't really want to have to save the files twice once cut from the comp in photoshop and again in fireworks juggling between the two applications is a bit inconvenient even with just one file but especially when you have potentially hundreds of files to save.
    Ive also turned off icon and windows thumbnail in photoshop preferences and although this has decreased the file size they are still quite large at 27k and save for the web is better at 4k for the png and 16k for the jpeg. Is there anyway to get Fireworks file saving performance in Photoshop ? it seems strange that the compression in Photoshop would be second rate in comparison to fireworks given they are both developed by Adobe and Photoshop is Adobes primary image editing software.

  • Help ...how to get the file size on a server

    Hi.I use this code to parse a file that is on a server.
    The question is: how can i get the file size (bytes size)?
    Thanks.
    //Open the file for reading:
    URL u = new URL(entry);
    InputStream inputXML = u.openStream();
    //Build document:
    DocumentBuilder builder = factory.newDocumentBuilder();
    doc = builder.parse(inputXML);

    Try this instead:
    URL u = new URL(entry);
    URLConnection conn = u.openConnection();
    // get the file size
    int size = conn.getContentLength();
    // open the input stream from the URLConnection (which is functionally the same as opening it directly from the URL)
    InputStream inputXML = conn.getInputStream();
    Shaun

  • I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. What is the best way to do this

    I am trying to make a pdf of a file and I need to get the file size to be no bigger than 10MB. Even when I save it, the image quality at minimum the file size is 10.9 MB. What is the best way to do this

    @Barbara – What purpose is that PDF for? Print? Web?
    If web purpose, you could convert CMYK images to sRGB. That would reduce the file size as well.
    A final resort to bring down file size is:
    1. Print to PostScript
    2. Distill to PDF
    That would bring file size down even more. About 20%, depending on the images and other contents you are using, compared with the Acrobat Pro method. If you like you could send me a personal message, so we could exchange mail addresses. I could test for you. Just provide the highres PDF without any downsampling and transparency intact. Best provide a PDF/X-4.
    I will place the PDF in InDesign, print to PostScript, distill to PDF.
    Uwe

  • How to get the file size (in bytes) for all files in a directory?

    How to get the file size (in bytes) for all files in a directory?
    The following code does not work. isFile() does NOT recognize files as files but only as directories. Why?
    Furthermore the size is not retrieved correctly.
    How do I have to code it otherwise? Is there a way of not converting f-to-string-to-File again but iterate over all file objects instead?
    Thank you
    Peter
    java.io.File f = new java.io.File("D:/todo/");
    files = f.list();
    for (int i = 0; i < files.length; i++) {
    System.out.println("fn=" + files);
    if (new File(files[i]).isFile())
         System.out.println("file[" + i + "]=" + files[i] + " size=" + (new File(files[i])).length() ); }

    pstein wrote:
    ...The following code does not work. Work?! It does not even compile! Please consider posting code in the form of an SSCCE in future.
    Here is an SSCCE.
    import java.io.File;
    class ListFiles {
        public static void main(String[] args) {
            java.io.File f = new java.io.File("/media/disk");
            // provides only the file names, not the path/name!
            //String[] files = f.list();
            File[] files = f.listFiles();
            for (int i = 0; i < files.length; i++) {
                System.out.println("fn=" + files);
    if (files[i].isFile()) {
    System.out.println(
    "file[" +
    i +
    "]=" +
    files[i] +
    " size=" +
    (files[i]).length() );
    }Edit 1:
    Also, in future, when posting code, code snippets, HTML/XML or input/output, please use the code tags to retain the indentation and formatting.   To do that, select the code and click the CODE button seen on the Plain Text tab of the message posting form.  It took me longer to clean up that code and turn it into an SSCCE, than it took to +solve the problem.+
    Edited by: AndrewThompson64 on Jul 21, 2009 8:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Creating .pdf from a ppt or .doc in acrobat 9 resulting in strangely large file sizes

    I am printing to .pdf from Microsoft Word and Powerpoint (previously Office 07 - now Office 10) and the file sizes are sometimes doubling in size. Also, for some larger documents, multiple .pdfs are generating as if acrobat is choosing where to cut off a document due to large file size and generating secondary, tertiary, etc., docs to continue the .pdf. The documents have placed images (excel charts, etc) but they are not enormous - that is until they are being generated into a .pdf. I had hoped that when i upgraded to Office 10, this issue would go away, but unfortunately, it hasn't. Any ideas? thoughts? Thanks so much!

    One thing that can happen with MS Office applications when an image contains transparency is the "image" is actually composed of multiple one pixel images when converted to PDF. This could be confirmed by examining the file. Try selecting the images using the TouchUp Object tool to see if what looks like a single image it entirely selected.

  • Get the file size of a file on the server.

    okay.. for my download manager i need to get the file size. I tried using the available method of inputstream, and the getContentLength() of URLConnection, which worked but only for webpages. so does anyone know how to do this? Sun does it in SDM, but i dont think the source is included. ill download it again and check.
    thanks.

    content-length is not guaranteed to be anythingi dont think so. correct me if i am wrong..
    http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#s
    c4.4 states -
    " When a Content-Length is given in a message where a
    message-body is allowed, its field value MUST exactly
    match the number of OCTETs in the message-body.
    HTTP/1.1 user agents MUST notify the user when an
    invalid length is received and detected."
    this sort of guarantees that if a file is being
    downloaded the content-length gives the size of the
    file. i am able to confirm this by sniffing the
    traffic of my download manager.This is only guaranteed if the content length field is present. :-)
    However, looking two paragraphs up:
    'All HTTP/1.1 applications that receive entities MUST accept the "chunked" transfer-coding (section 3.6), thus allowing this mechanism to be used for messages when the message length cannot be determined in advance.'
    There is mechanism built in for cases where the size cannot be determined.
    Regards,
    Bhaveet

  • Aperture is exporting large file size e.g. original image is 18.2MB and the exported version (TFF 16 Bit) is 47.9MB, any ideas please

    Aperture is exporting large file size e.g. original image is 18.2MB and the exported version (TFF 16 Bit) is 47.9MB, any ideas please

    Raws, even if not compressed, Sould be smaller than a 24-bit Tiff, since they have only one bitplane. My T3i shoots 14 bit 18MP raws and has a raw file size of 24.5 MB*. An uncompressed Tiff should have a size of 18 MP x 3 bytes per pixel or 54 MB.
    *There must be some lossless compression going on since 18 MP times 1.75 bytes per pixel is 31.5MB for uncompressed raw.

  • Facebook application grow large file size

    Why facebook applications grow larger and larger file size. What can I do. Since this program is to use the file size is big time. I use facebook version 4.0.3 on iphone4 run on iOS 5.0.1.
    thank you.
    Eak.

    Most of the logs rotation for the different componets can be set in EM console but if you just want to do it with a cron or script here is what I have used in the past. Edit it to your needs.
    #!/bin/sh
    ORACLE_HOME=/home/oracle10FRS
    apache_logs=$ORACLE_HOME/Apache/Apache/logs
    webcache_logs=$ORACLE_HOME/webcache/logs
    sysman_logs=$ORACLE_HOME/sysman/log
    j2ee_logs=$ORACLE_HOME/j2ee/OC4J_BI_Forms/log/OC4J_BI_Forms_default_island_1
    also_j2ee=$ORACLE_HOME/j2ee/home/log/home_default_island_1
    max_size=1500000000
    for file in `ls $apache_logs/*_log`
    do
         size=`ls -l $file | awk '{print $5}'`
         echo "File $file is $size bytes"
         if [ "$size" -ge "$max_size" ]
         then
              echo "That's too big. Truncating"
              >$file
         fi
    done
    for wfile in `ls $webcache_logs/*_log`
    do
         size=`ls -l $wfile | awk '{print $5}'`
         echo "File $wfile is $size bytes"
         if [ "$size" -ge "$max_size" ]
         then
              echo "That's too big. Truncating"
              >$wfile
         fi
    done
    for sfile in `ls $sysman_logs/*log`
    do
         size=`ls -l $sfile | awk '{print $5}'`
         echo "File $sfile is $size bytes"
         if [ "$size" -ge "$max_size" ]
         then
              echo "That's too big. Truncating"
              >$sfile
         fi
    done
    for jfile in `ls $j2ee_logs/*.log`
    do
         size=`ls -l $jfile | awk '{print $5}'`
         echo "File $jfile is $size bytes"
         if [ "$size" -ge "$max_size" ]
         then
              echo "That's too big. Truncating"
              >$jfile
         fi
    done
    for j2file in `ls $also_j2ee/*.log`
    do
         size=`ls -l $j2file | awk '{print $5}'`
         echo "File $j2file is $size bytes"
         if [ "$size" -ge "$max_size" ]
         then
              echo "That's too big. Truncating"
              >$j2file
         fi
    done

  • Does FW CS5 Mac crap out w large file sizes?

    Does FW CS5 Mac crap out with large file sizes like CS4 did? It seems like files over a 4-5MB tend to be flaky... Is there an optimum file size? I'm running a Mac Tower 2.93 GHz Quad Core, w 8 GB RAM

    Why not download the trial version and find out?

  • Why do I get inconsistent file sizes & quality?

    I use Premier Pro 5.0, admittedly not knowledgeable on the tech side. I create projects in a timeline, string sequences into a 30-min movie, and then export from the timeline to "media". In so doing, I create an avi video file. But the resulting video files can vary dramatically in size (500 mb to 8 gb). I now notice that the larger file size gives me a higher quality end result when I author a DVD. I also see that same quality difference when playing back the video file on my computer, before making DVD's.
    I use default project settings. Yet something is making my projects inconsistent, either in production or initial set-up.  What might I be missing?

    >use default project settings
    See 2nd post for picture of NEW ITEM process http://forums.adobe.com/message/3776153
    -and a FAQ on sequence setting http://forums.adobe.com/message/3804341
    The tutorial list in message #3 http://forums.adobe.com/message/2276578 may help

  • Is it best to upload HD movies from a camcorder to iMovie or iPhoto.  iMovie gives the option for very large file sizes - presumably it is best to use this file size because the HD movie is then at its best quality?

    Is it best to upload hd movie to iPhoto or iMovie?  iMovie seems to store the movie in much larger files - presumably this is preferable as a larger file is better quality?

    Generally it is if you're comparing identical compressors & resolutions but there's something else happening here.  If you're worried about quality degrading; check the original file details on the camera (or card) either with Get Info or by opening in QuickTime and showing info. You should find the iPhoto version (reveal in a Finder) is a straight copy.  You can't really increase image quality of a movie (barring a few tricks) by increasing file size but Apple editing products create a more "scrub-able" intermediate file which is quite large.
    Good luck and happy editing.

Maybe you are looking for

  • Discoverer 9iASv2: does not run, produces java errors

    Hi, I am evaluating Discoverer9ias v2 for my company. We have set up 9iAs infrastructure on a Win2K box, with the main 9ias BI and Forms on another Win2K box. After installing everything, the disco plus demo ran fine for a few hours. After that the 9

  • SolMan and multiple SAP customers

    As a consultant, I'm in the middle of installing and configuring SolMan 4.0 for a client.  This client is currently running many SAP systems as they have gone through a couple mergers over the past few months/years.  As a result, they have multiple S

  • My iPod displays a red circle with an X in it.

    My ipod dispays a red circle with a red X in the middle?

  • 8600 Error in Solution Center

    I have an 8600 HP all in one printer. When I open the HP solution center i get the following error, even though my printer works fine. HP Solution Cnter cannot run because your device installation is not complete. Why is this error occurring as the p

  • Hash key doesn't work :(

    Guys this is doing my head in. I am using a UK keyboard and a UK Macbook Pro 2008 (Late). I can't use a hash key at all using ALT + 3 or SHIFT + 3. It shows hash on they keyboard viewer but it never does output the icon on the screen At the minute my