I'm using Sharepoint 2007 and unfortunately don't have any ways to server site scripting, no C# or PowerShell.
Is there any way to get total number of files in a given Library using SPServices ?
It would be great if I could also access files attributes. So for instance I have attribute called 'FileType' use to store technical type of the document. Lets say 'TECH1', 'TECH2', 'TECHN' I would want to get count of files with only FileType = 'TECH2'.
Also attribute 'Modified'. Any chance to loop through files in a library and count all files older than for instance today - 365 days ?
Maybe it can be done easier than SPServices ? I'm not that much web programmer :(
I was playing around with:
myObject = new ActiveXObject("Scripting.FileSystemObject");
f = myObject.GetFolder("\\\\mysite\\sites\\space\\Library\\");
myDate.setDate(myDate.getDate()-365);
var FSo = new Enumerator(f.Files);
for(i=0;!FSo.atEnd();FSo.moveNext())`
But this turned out to be dead end working from my local but not on the server
Updated code:
I've just did what you wrote and put the code on the server like below but nothing is being display. How do I check response xml ?
Thanks
<script language="javascript" type="text/javascript">
var soapEnv = "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
<soap:Body>
<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>
<listName>Library</listName>
<query>
<Query>
<Where>
<Lt>
<FieldRef Name='Modified' />
<Value Type='DateTime'>
<Today Offset = '-15' />
</Value>
</Lt>
</Where>
</Query></query>
</GetListItems>
</soap:Body>";
$.ajax({
url: "/_vti_bin/lists.asmx",
type: "POST",
dataType: "xml",
data: soapEnv,
complete: ProcessListItems,
contentType: "text/xml; charset=\"utf-8\""
});
function ProcessListItems(xData, status) {
//to count items
var itemCount=$(xData.responseXML).find("z\\:row").length;
//to iterate through items
$(xData.responseXML).find("z\\:row").each(function()
{
alert(itemCount);
}
</script>