Get Network Folder Owner and Size

Andrew

  • Joined: Mar 12, 2010
  • Posts: 32

Fri 8/6/2010 - 15:49

Hello,

My goal is to create a job (running every hour or every ten minutes; I know how to trigger this) that:

1. Gets the size and owner of every folder in a certain network directory

2. If the size of the folder is more than 20 GB, and the amount of space left on the network drive is less than 20 GB, send email to the owner of that folder.

I know how to get the owner, folder size, and drive space remaining by using Windows Explorer, but I'm not sure how to transfer that information into WinAutomation.  I don't think I can use the macro recorder because there isn't a fixed number of folders in the network directory.

The "Set Variable" action with %FolderVariable.Owner% and %FolderVariable.Size% gave me an error message.  I would also prefer to avoid using "Get Files in Folder" and adding up the size of all files in the folder because I'm worried that might take too much time, but maybe that is the only way to compute the size of a folder.

Any suggestions?

Andrew

#1

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Mon 8/9/2010 - 17:47

Hello Andrew, I have attached a sample job that will help you make what you want. Just remember to change the folder in the 1st action. This job uses the command prompt to get the size of all the files in each directory and according to the result of the comparison made, it performs specific actions. Let me know if this is what you were after, or whether you need any help to customise it further Kindest regards :) Samantha

get folder-owner.waj

#2

Andrew

  • Joined: Mar 12, 2010
  • Posts: 32

Wed 8/11/2010 - 22:46

Hello Samantha,

It hadn't occurred to me that I could get the information I needed simply by using the DOS "dir" command.  The job you created for me wasn't quite what I was looking for, but I used some of the ideas in it to write the job that I actually needed, which is very close to being complete (and proved to be quite a bit more complicated).  Thanks for your help.

I discovered that using /O was the way to get the DOS command to display the owner of the file, but extracting it was a bit harder.  Do you know of a more efficient way to split a line of text by an arbitrary number of spaces than splitting by "Space x1" and then removing every empty list item?  For example:

"           abc    def      ghijklmn  "

becomes a list containing the 3 items "abc", "def", and "ghijklmn", even though the number of spaces between each sequence of letters is different.

Andrew

#3

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Thu 8/12/2010 - 12:30

Hello Andrew, Have I got it right, you want as an output the three values, and want to get rid of the spaces between the values no matter how many of them exist.. is that right? Well.. you can use the "Replace Text" action and configure it as suggested below: Text to parse: " abc def ghijklmn " (or variable holding text line) Text to find: (\s{2,}) (This regular expression, actually finds any number of spaces that is more than 2 in a row) Replace with: %" "% (Replacing them with a single space) Tick the option "Use Regular Expressions.." this way, the line replaced will be: " abc def ghijklmn " ..then using the Split Text action for the %Replaced% variable you can get all the items that are empty. Let me know whether this was what you were after. Samantha

#4

Andrew

  • Joined: Mar 12, 2010
  • Posts: 32

Thu 8/12/2010 - 17:08

Excellent, that was exactly what I was looking for!  The job seems to be working perfectly now.  Thank you very much!

Andrew

#5

Samantha

  • Joined: Apr 23, 2010
  • Posts: 2326

Fri 8/13/2010 - 9:48

My pleasure! :) Samantha

#6
Not a member yet? Register

Copyright 2013 - Softomotive Ltd