Folder actions question

Posted:
in macOS edited January 2014
ok, so i guess this is a two part question. one, can it do this. two, can anyone help me out on it, as i'm completely lost with applescript.



i'm doing some automated backups at work. i realized the other day it would be nice to see how quickly the backup files are growing. it would help me decide when i'll need to buy new hardware, who might be using up too much space etc.



however, going in every day and logging the file sizes sounds like a pain in the ass. no way i'm going to remember to do it every day, so i'd like to be able to have a script that does it for me.



what i'd like is a script that takes the files name and size info, and enters it into an excel file. is that possible?

Comments

  • Reply 1 of 13
    ipodandimacipodandimac Posts: 3,273member
    do your daily backups really vary enough in size to warrant making graphs? just get a huge hard drive and dont worry about it. (sorry i couldnt be of more help)
  • Reply 2 of 13
    alcimedesalcimedes Posts: 5,486member
    well, i'm backing up approx. 60 machines every day. i'd like to know how quickly they're increasing in size, so i know approx. at what rate i'll have to buy additional drive for budgeting. plus it would just be cool to have a size graph.



    as of now i've got approx. 1.5 TB of storage, and i'm sure there will be more in the future.
  • Reply 3 of 13
    defiantdefiant Posts: 4,876member
    The backup files are in a folder somewhere, yes? Are they files, or folders with some content in them? Or do you just need something which takes a folder somewhere, and makes a list of its contents and file sizes?
  • Reply 4 of 13
    kraig911kraig911 Posts: 912member
    what are you using to backup?
  • Reply 5 of 13
    alcimedesalcimedes Posts: 5,486member
    the files are all in a folder on an external RAID. each backup script has two files. a data file and catalog file. (using Retrospect)



    the data files are the only ones i care about, but i wouldn't mind getting the catalog file info as well.
  • Reply 6 of 13
    defiantdefiant Posts: 4,876member
    If you say backup script, does that mean that for every day when the backup runs, two new files get created? Or are the just updated?



    I think this is very well possible through AS. I will have a look.
  • Reply 7 of 13
    alcimedesalcimedes Posts: 5,486member
    each day the files are updated, and increase in size. however, the files names stay the same.
  • Reply 8 of 13
    alcimedesalcimedes Posts: 5,486member
    hate to bump my own thread, but any thoughts?
  • Reply 9 of 13
    defiantdefiant Posts: 4,876member
    I have various snippets of code, but I will have to bring them together, so that it's going to work.
  • Reply 10 of 13
    defiantdefiant Posts: 4,876member
    And this looks pretty difficult.



    This is the code to get the size of any folder. But not to get the size of each of the files...



    Code:


    set byteSize to size of (info for alias "yourath:to:file")

    set size_ to convertByteSize from byteSize



    to convertByteSize from byteSize -- by Nigel Garvey

    if byteSize is greater than or equal to 1.099511627776E+12 then -- Terabytes (2 ^ 40)

    ((byteSize / 1.099511627776E+12 div 0.01 / 100.0) as string) & " TB"

    else if byteSize is greater than or equal to 1.073741824E+9 then -- Gigabytes (2 ^ 30)

    ((byteSize / 1.073741824E+9 div 0.01 / 100.0) as string) & " GB"

    else if byteSize is greater than or equal to 1048576 then -- Megabytes (2 ^ 20)

    ((byteSize / 1048576 div 0.01 / 100.0) as string) & " MB"

    else if byteSize is greater than or equal to 1024 then -- Kilobytes (2 ^ 10)

    ((byteSize div 1024) as string) & " K"

    else

    (byteSize as string) & " bytes"

    end if

    end convertByteSize



  • Reply 11 of 13
    defiantdefiant Posts: 4,876member
    of course, it could be hardcoded into the the script. but that's not really what I'd like? anyways, maybe the scripters over at MacScripter can help you.



    Thing is, I've tried a lot now, but I don't want to spend more time on it.
  • Reply 12 of 13
    toweltowel Posts: 1,479member
    Wouldn't it be easier to just write a little shell script to do this? All you want is the file size of a few files of known names, right? Write a script that fetches the names and sizes and outputs to a text file, and insert the script into your /etc/daily script so it executes every day, once a day.



    I'm not much help with the details, though. There must be a "filesize" shell command, but I don't know what it is. You could probably dump the output of "ls -l", parse it with sed, append the date, and output it to a text file.
  • Reply 13 of 13
    defiantdefiant Posts: 4,876member
    and if you want, we can still wrap these commands into a applescript.
Sign In or Register to comment.