CAML query to delete a file version

Can someone please help me.
I need to get the CAML query that will allow me to delete a version of a sharepoint document?

Hi,
If you want to delete versions of a SharePoint document, we can use C# code or PowerShell to achieve it.
http://blogs.msdn.com/b/paul_cardon/archive/2010/07/12/deleting-versions-from-a-sharepoint-list-item.aspx
http://matthewyarlett.blogspot.com/2013/08/listing-and-deleting-sharepoint.html
If you only want to delete a special version of a document, we can use LINQ to get the version by some conditions.
Example:
var result = item.File.Versions.Cast<SPFileVersion>().Where(v => v.Created.AddHours(-8).ToShortDateString() ==DateTime.Now.ToShortDateString()).ToList();
Best Regards
Dennis Guo
TechNet Community Support

Similar Messages

  • CAML Query to Exclude the file names inside "Archive" folder

    Hi,
    I need to exclude the files which is already in the "Archive" folder in the same document library. Is there any CAML query to filter only the files from the document library(Exclude the "Archive" folder) files.
    Thank you,
    Mylsamy

    Hi,
    Below link might help you 
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/35e799a1-9360-46e5-8719-dd35fdace7ea/filter-document-library-folder-through-caml-query?forum=sharepointdevelopmentlegacy 
    Thanks
    Sivabalan

  • Delete master file & versions fromhard drive ... completely!!!

    I just bought a new iMac yesterday and imported 12,000 pictures on the hard drive. Strarted my clean up using delete master image and all version ... files gets transfered into the aperture trash! ... i empty the trash ... files STILL REMAIN ON MY HARD DRIVE.
    Why is that?
    What am I doing wrong.
    Files were imported in a folder I CREATED ... I called it PHOTOS
    Thanks everyone for your help .. a little bit discouraged!
    Eric

    Don't be discouraged. This is a feature, not a bug. You may not like it, but you should know how it works. Complete instructions are found many places in the Help file. Search under "Trash".
    Deleting items in Aperture can be a four-step process. Each step but the last is reverseable.
    1. Mark photo as "rejected".
    2. Move photo or other items to the Aperture Trash. This is just a special container called "Trash".
    3. Empty the Aperture Trash. This moves the items out of Aperture's control, and put them in your system trash.
    4. Empty the system trash. This is done via Finder.

  • Check powershell.exe file version

    I am learning SCCM 2012 and I put together a query to check the file version of powershell.exe to see if the computers are running v2.0 or v3.0. Here is the query. When I run it, nothing shows up. I have a few computers with powershell installed.
    select SMS_R_System.Name, SMS_R_System.LastLogonUserName, SMS_G_System_SoftwareFile.FileVersion from  SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName
    = "powershell.exe" order by SMS_R_System.Name
    When I change powershell.exe to winword.exe I get more than 100+ computers listed. I even give it the file path (C:\Windows\SysWOW64\WindowsPowerShell\v1.0) but it still does not work
    Thanks for your help
    Freddy91761_1

    This might interest you as well
    http://be.enhansoft.com/post/2014/01/15/PowerShell-Inventory-Reports.aspx
    Please remember to click "Mark as Answer" or "Vote as Helpful" on the post that answers your question (or click "Unmark as Answer" if a marked post does not actually
    answer your question). This can be beneficial to other community members reading the thread.
    This forum post is my own opinion and does not necessarily reflect the opinion or view of my employer, Microsoft, its employees, or MVPs.
    Twitter:
    @alexverboon | Blog: Anything About IT

  • Preview file version can't be deleted

    I have a MacBook with Lion 10.7.2 build 11C74 and I used Preview v 5.5.1 (719.11) to edit a pdf of a form downloaded from the internet.
    The file was moved to my Desktop, opened and edited.
    I saved a version of the file and another file appeared on my desktop. I deleted the original file but cannot delete the other.
    It's in this image, bottom right, but NOT in the finder:
    How do I delete this file?
    Thanks in advance.

    Definitely not a virus, or any other kind of malware.
    An xlsx file is an Excel file. What happens when you try to open or delete it?

  • Tried to download trail version of CS6 had problems with the instalation primarily - did not work (Windows 7). So deleted all files and re-installed the creative cloud now no apps showing on CC? Please help!

    Downloaded CS6 from the cloud on trial version a few weeks back. During instalation my computer crashed and left it kind of partially installed i think. I deleted the files i could find to try and re-instal. Have managed to get the creative cloud back but when i load it up im not given any options - no apps or home or anything just the shell. Does anyone know whats up or cangive me some advice to get my trial please. Many thanks

    When I try to install trial version now it brings up the cloud but nothing happens. Any ideas? Thankyou

  • Retrieve all items in a list by caml query then write it to a word file page by page

    Dears,
    Greetings
    I have some code which will retrieve all items of a list with caml query.
    Now i want to generate a word file with all these retrieved data. I am using foreach here to get all the items in a SPListItemCollection. Now my question is how i can write all the retrieved items inside the word file?
    see the below code which is writing only the last row item of the SPListItemCollection inside word file. I want to write all the retrieved rows inside this word file.
    SPQuery qry = new SPQuery();
    qry.Query = "<Where><Eq><FieldRef Name='Department' /><Value Type='Text'>HR DEPARTMENT</Value></Eq></Where>";
    SPListItemCollection listItems = KPILIst.GetItems(qry);
    foreach (SPListItem item in listItems)
    lblBadgeNo.Text = item["Badge No"].ToString();
    lblName.Text = item["Name"].ToString();
    lblPosition.Text = item["Position"].ToString();
    lblDept.Text = item["Department"].ToString();
    lblHireDate.Text = item["Hire Date"].ToString();
    lblGrade.Text = item["Grade"].ToString();
    lblCurStatus.Text = item["Status"].ToString();
    string FinalOut = "";
    FinalOut = "<table cellpadding=0 cellspacing=0><tr><td style='height:30px;'></td></tr><tr><td style='height:22px;'></td></tr>";
    FinalOut = FinalOut + "<tr><td style='text-align:justify;font-size:22px;'>" + lblBadgeNo.Text + "</td></tr>";
    FinalOut = FinalOut + "<tr><td style='text-align:justify;font-size:22px;'>" + lblName.Text + "</td></tr>";
    FinalOut = FinalOut + "<tr><td style='text-align:justify;font-size:22px;'>" + lblDept.Text + "</td></tr>";
    FinalOut = FinalOut + "<tr><td style='text-align:justify;font-size:22px;'>" + lblHireDate.Text + "</td></tr>";
    FinalOut = FinalOut + "</table>";
    System.Text.StringBuilder strBody = new System.Text.StringBuilder("");
    strBody.Append("<html " + "xmlns:o='urn:schemas-microsoft-com:office:office' " + "xmlns:w='urn:schemas-microsoft-com:office:word'" + "xmlns='http://www.w3.org/TR/REC-html40'>" + "<head><title>EPCCO : HR Comapny Letter</title>");
    strBody.Append("<!--[if gte mso 9]>" + "<xml>" + "<w:WordDocument>" + "<w:View>Print</w:View>" + "<w:Zoom>90</w:Zoom>" + "<w:DoNotOptimizeForBrowser/>" + "</w:WordDocument>" + "</xml>" + "<![endif]-->");
    strBody.Append("<style>" + "<!-- /* Style Definitions */" + "@page Section1" + " {size:8.5in 11.0in; " + " margin:1.0in 1.25in 1.0in 1.25in ; " + " mso-header-margin:.5in; " + " mso-footer-margin:.5in; mso-paper-source:0;}" + " div.Section1" + " {page:Section1;}" + "-->" + "</style></head>");
    strBody.Append("<body dir=rtl lang=EN-US style='tab-interval:.15in'>" + "<div class=Section1>" + FinalOut.ToString() + "</div></body></html>");
    Response.AppendHeader("Content-Type", "application/msword");
    Response.AppendHeader("Content-disposition", "attachment; filename=Eval_" + lblBadgeNo.Text + ".doc");
    Response.Write(strBody);
    Regards
    Shaji
    I am new to SharePoint

    Hello,
    you can try with OpenXML SDK to create word file. I found one link for your reference:
    http://sharepointplace.blogspot.in/2009/12/programmatically-creating-word.html
    Another way is , use Microsoft Word Object Library.
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/5b82c0b5-ecaf-40f2-a68a-c7c17c85414f/create-word-documents-by-c?forum=csharpgeneral
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • After upgrading Lightroom on a mac. Deleting the older version along with old catalogs and files?

    Can I delete the older version along with old catalogs and files? and what is the best way to go about this? Thankyou : )

    manually uninstall then, Manually uninstall Lightroom

  • REST API Query for file Versions - current version

    Hi,
    I have referred to the list of API query options from this link:
    https://msdn.microsoft.com/en-us/library/office/dn450841.aspx .
    As described in the post, the query  goes as below
    url: "<app web url>/_api/SP.AppContextSite(@target)/web
        /getfilebyserverrelativeurl('/Shared Documents/filename.docx')/versions
        ?@target='<host web url>'",
    This does not return the current file version details. Is there a way to get those details in the same query or should we place another query to get the current version file details as below
    url: "<app web url>/_api/SP.AppContextSite(@target)/web
        /getfilebyserverrelativeurl('/Shared Documents/filename.docx')
    Thanks,
    Meena

    Hi Meena,
    In FileVersion endpoint, it will only return the old versions of a file.
    If you want to retrieve all versions(including) of a file, there will be a need to run another request for the current version only, though which might cause extra workload.
    Thanks
    Patrick Liang
    TechNet Community Support
    Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
    [email protected]

  • Cant delete apple files or update to newest itunes version windows 7 64 bit

    cant delete apple files or upgrade to new itunes version

    What error messages are you getting during the update attempts, candace? (Precise text, please.)

  • Crashes when printing, deleted preferences file. Didn´t help. Lightroom version 5.6

    Printing module Lightroom
    using Lightroom templates
    Reinstalled Lightroom with latest update
    Printing from Epson Easy photo print works fine
    The problem must be a Lightroom issue. Searched forum for alternatives. And came up with deleting preferences file option
    Tried this now, but didn't solve the issue for me.
    Using OS X, 10.9.5, Lightroom 5.6
    Any suggestions to the problem other than "exporting files and use Epson Photo print"
    Thanks for your help and responses to the issue.
    Jon

    Extract of error message after print:
    Screen shot in bottom Thread 29, as I understand that is where the real issue is
    Any suggestion for helping in solving the issue?
    Screen shot of Thread 29

  • How to delete the beta version in icloud?

    I purchased iWork half an year ago and I use it in icloud. But since the beta version has appeared, it´s not possible to work with my own software. Who knows how to delete the beta version from icloud?

    You can't delete it.
    Why do you need to?  Why can't you just work with your documents like everyone else does, by opening iWork software on your Mac and using File > Open, etc to see your docs that are in iCloud?  Why would you need to use your browser?

  • Help needed - OS Command foe deleting a file from Appplication server.

    Hi,
    I have requirement, where in i need to delete a file from the application server. It has to be done automatically. I thought of using OS Command for achieving the same. Can anyone help me in achieving it. The OS of my application server system is UNIX.
    Thanks in advance!!
    P.S: Points will be rewarded.

    Hello Sudeep,
    If you define the command for each operating system using transactions SM69 (You can test it with SM49) and then call it using SXPG_COMMAND_EXECUTE which contains a parameter defining the operating system (SY-OPSYS)
    then it does not matter which operating system is running, the function module always calls the correct version of the command.
    So, for example you could define a command 'OS_COMMAND'
    which deleted a file. This would have one version for Dos
    which said 'del', and a second version for unix which said 'rm'.
    The correct command would be specified by the call to SXPG_COMMAND_EXECUTE because the operating system parameter differentiates between the two commands.
    [USING PROCESS CHAINS IN SAP BW|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0a7cd90-0201-0010-49a1-d730a56895f4]
    SXPG_COMMAND_LIST_GET – Reads a list of external OS commands
    Thanks
    Chandran

  • Delete the file from the external hard drive

    deleted adobe reader 10, delete the file from the external hard drive. how to restore

    What is your operating system & version?
    How did you "delete" Adobe Reader?
    What "file" did you delete?
    What do you want to restore?

  • How do you delete a file from an iPad?

    How do you delete a file from an iPad?
    There are 2 versions of a document file on my iPad.
    I want to get rid of the obsolete one.
    The iPad Users Guide does not describe how to delete a document file.
    This is very frustrating!

    The iPad Guide is for the iPad itself, not other apps you may install.
    If you use Pages then read the online help here: http://help.apple.com/pages/ipad/2.2/ - specifically this: http://help.apple.com/pages/ipad/2.2/#/tancfc4d5c02
    Delete a document from your iOS device
    In the document manager, tap Edit.
    When the documents begin to jiggle, tap the ones you want to delete.
    Tap , then tap Delete Documents.To cancel, tap anywhere in the document manager background, or tap Done.

Maybe you are looking for

  • Getting error while Active dricetory configuration in WL 10.2

    Hi I am grtting following while conneting to ldap server, I have configured security realms. It is fine because I can see all user at User and Group tab, but when I click on any link over that page it run me this error on server consol... <Feb 23, 20

  • Organizer will not load in Windows 8

    Organizer will not load in Windows 8 directly.  If Editor is opened first Organizer will load photos but THEN converts them to hourglasses.  Hourglasses will open if double clicked.  I have no idea what is going on.

  • Error in simple Generics program

    Why is this code not compiling? When I changed the <String> to <T> then it works. My question is why should the code listed below fail. Error: non-static class String cannot be referenced from a static context public class SimpleGenerics1<String> {  

  • Error when posting inventory differences

    We receive an error when trying to post an inventory difference with MI07.  The error message is "Account xxxxxx requires an assignment to a CO object" (SAP message KI235).  I've looked at the account, which is a cost element, using KA02 and there is

  • Rights Management

    Well I phoned adobe UK today to try and ask some questions about the purchase of the rights management extensions and have not experienced such poor customer support, ever, in my life! I had asked for e-mail contact before now and had zilch response.