Keep files from first of the month for a year

We have a series of folders with subfolders that have logfiles in them. Each folder has new log files generated daily. However on occasion, a log file is not generated for a day or for a few days.
I want to keep the log file in each folder for the first of each month, or as close to the day as possible for a year and delete all files older than a year. I also want to delete all files in that folder that are not from the first of the month.
So, on August 30, 2014 Folder 1 may have log files from each day in August except for August 1. When I run my script on September 1, I want the folder to have files:
August 02, 2014.log
July 01, 2014.log
June 01, 2014.log
If the first log file is August 5th, then I want to keep that one and delete the rest.
I currently have 30+ folders that get daily log files. It takes a long time to go into each folder, see which log is closest to the beginning of the month, delete the remaining files from that month, then find the log files from over a year ago and delete
that one.
Ive tried a few iterations but, keep getting stuck. Any help would be appreciated.
Thanks!
Steve

Hi Mike,
I have been looking at those.  One of the problems Ive had is with the date/time format.
For instance, if I issue
$testDate=$(Get-Date).addDays(-$(Get-Date).Day).addMonths(-3)
$testdate gets set to Saturday, May 31, 2014 12:51:59
When I look for files based on 5/31/2014 it doesn't match because there are no files created at 12:51:59
Im not sure how to convert $testdate to date only and not time.  Saturday, May 31, 2014 12:51:59 PM
Saturday, May 31, 2014 12:51:59 PM

Similar Messages

  • I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is j

    I am batch processing in PS 2014 (watermark and saving as jpeg from ps file). I get the message for some but not all 'this file needs to be saved as a copy with this option'. And then I have to save it manually. Does anyone know why this happens? (It is just a plain photoshop file, a watermark is added, then save as jpeg - the jpeg is saved to a different folder than the original photoshop file.)  It happens for about 10 of 30/40  files approximately . Thank you, Kathryn

    I believe I have figured it out - I need to flatten the image, even though there are no layers except for layer 0, first.

  • Find 3rd friday of the month for a given date

    how to find out 3rd friday of the month for a given date? I can always pass the first day of the month as input
    eg, input date is 01-JAN-09. need to get the 3rd friday 16-JAN-09 (Jan has 5 fridays 02, 09, 16,23,30)
    input date : 01-feb-09, need to get 20-feb-09
    Edited by: user520824 on Apr 1, 2009 12:30 PM

    NLS independent solution:
    SELECT  DT,
            TO_CHAR(DT,'FMDay') day,
            CASE
              WHEN TRUNC(TRUNC(DT,'MM') + 7,'IW') - 3 < TRUNC(DT,'MM') THEN TRUNC(TRUNC(DT,'MM') + 7,'IW') + 18
              ELSE TRUNC(TRUNC(DT,'MM') + 7,'IW') + 11
            END THIRD_FRIDAY_OF_THE_MONTH
      FROM  (
             SELECT  TO_DATE(LEVEL || '/2009','MM/YYYY') DT
               FROM  DUAL
               CONNECT BY LEVEL < 13
    DT        DAY       THIRD_FRI
    01-JAN-09 Thursday  16-JAN-09
    01-FEB-09 Sunday    20-FEB-09
    01-MAR-09 Sunday    20-MAR-09
    01-APR-09 Wednesday 17-APR-09
    01-MAY-09 Friday    15-MAY-09
    01-JUN-09 Monday    19-JUN-09
    01-JUL-09 Wednesday 17-JUL-09
    01-AUG-09 Saturday  21-AUG-09
    01-SEP-09 Tuesday   18-SEP-09
    01-OCT-09 Thursday  16-OCT-09
    01-NOV-09 Sunday    20-NOV-09
    DT        DAY       THIRD_FRI
    01-DEC-09 Tuesday   18-DEC-09
    12 rows selected.
    SQL> SY.

  • Have CS5 and CS6.  Need to reduce size of file from 6Mb to 2 Mb for contest purposes without losing original

    Have CS5 and CS6.  Need to reduce size of file from 6Mb to 2 Mb for contest purposes without losing original

    Just save the document to a new jpeg file name using a lower quality setting or re-size the image down in  size the save a high quality smaller new jpeg image.

  • How can organize photos by year?  by putting a folder inside of a folder?  So putting all of the events for one year under one folder so that it keeps them seperate?

    Looking for help in organizing my photos.   I would like to organize them so that i can put all of the events for a year into one folder  (i would like to keep multiple events under a folder)?  Help please?!

    Like Larry suggested:
    Click to view full size
    The top folder could be named 2011.  In it could be 12 smart folders each with the following criteria:
    Date is in the range"  mm/01/yyyy to mm/31/yyyy.
    So the 2011 folder would have 12 month smart albums each with the photos for that particular month.
    Or you can use the search by date function at the bottom of the window to search by year, month, week or day.
    OT

  • How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    Create one on the first Tuesday, select repeat/monthly and take the option at the bottom.

  • How do I move a file from "Recents" in Adobe Reader for Android to a folder in "Documents"?

    How do I move a file from "Recents" in Adobe Reader for Android to a folder in "Documents"?
    Files from Google Drive are appearing in "Recents" where I cannot organize them hierarchically.
    I cannot find a user manual for Adobe Reader for Android with this level of detail.

    Hi John,
    Files opened via Google Drive are not listed in ‘Documents' section of Adobe Reader, because they are read only files. If you really want to save these files to ’Documents' then please follow below steps -
    Open the file from Google drive in Adobe Reader.
    Tap on the Comment icon placed at top toolbar(Second icon from the beginning)
    You would encounter a 'Read-Only document’ dialog, tap on Save button.
    Once you performed above steps , your file will be saved in /Download/Adobe Reader/ folder.
    Hope this will solve your problem.
    Thanks,
    Adobe Reader Team

  • ITunes 10.6.3 Mac running 10.7.3 not responding I have deleted iTunes and reinstall iTunes and it keeps happening I also scanned the computer for any trojans and any other possible viruses but the pc is running perfect waft do I do ? Please help me ?

    I need help iTunes 10.6.3 Mac running 10.7.3 not responding I have deleted iTunes and reinstall iTunes and it keeps happening I also scanned the computer for any trojans and any other possible viruses but the pc is running perfect waft do I do ? Please help me ?

    Hey thanks for replying.
    Here's what I did:
    First I tried the Winsock reset in the Command prompt. Nothing changed.
    Next, I tried the instructions on http://http://support.apple.com/kb/TS4123. The only other program that came up on the 'Winsock Providers' tab on the program was 2 Windows Live applications, which I can do without. So I deleted all Windows Live Applications.
    I did the Winsock reset in the Command Prompt again and rebooted my comp.
    Unfortunately, nothing has changed. iTunes keeps freezing at various stages of the sync, then shows the candy cane-striped bar with either the words 'Finishing sync' or 'Cancelling sync', before showing the Apple logo.
    Sometimes, iTunes gets to the syncing stage - "Copying # of ####" - where it will trudge through the first, second and third tracks before flashing "Copying 4 of ####" for a split second and I catch "Cancelling sync" briefly before the Apple logo appears.
    Again, I've repeated the steps I mentioned in my previous post. Does ANYONE know when the new version of iTunes is set to be released?! This one is driving me INSANE, to say the least!!

  • Howto make created folders/ files from one teacher, read only for other teachers?

    Hello there,
    as an admin @ school I was wondering how to make created folders/ files from one teacher, read only for other teachers?
     - In a 2008domain, created a group "teachers"
     - created a folder "teacher data" where all teachers have read/write permissions
    ideal,a teacher who make's a folder in "teacher data" should be the only oen who is able to add file's to that folder and dele that folder or files. Other teachers may be able to read the content of the folder.
    Is this possible to set up and how?
    many thanks.
    Nico.
    rds

    Hi Nico,
    You could set the permissions below to resolve the issue:
    For the root folder "teacher data": give the full control permission to CREATOR OWNER – "Subfolders and files only" and give the read/write permissions to the group "teachers"– "This folder only".
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • How to create a text variable for Calender Yr/Month depending on the prompt for calendar year

    Hi everyone
    Please assist on this issue:
    i have created a Bex report that has an offset for 12 months from the current calender month, i tried to use text variables to replace the calender months but i just learned now text variables from Bex dont work in BO, so I would like to create a prompt in BO to enter Calendar Year and then based on the input(Calender Year) the Webi report must display a 12 months for that Year.
    Please also indicate where exactly  i have to click in order to get that "Helpful icon "  when the my issues have been resolved, because i searched it and havent seen it anywhere on the communications
    Thanks in Advance
    Ole

    Hi Gill
    In BO I recieve my all months for existing data  and when i create a prompt for Calender Year the months in the report still has those text varibale for exampl if i enter 2011 on the prompt the text remains for the year that was already there wen i created my text variable... so its not dynamic.....
    So if i have text variables in Bex it will display like this in Webi in which it wont change if i put in 2011 as input for the prompt...

  • What is the list of file prefixes that make a file appear first in the finder?

    Hi!
    I was just curious :
    What is the list of file prefixes that make a file appear first in the finder?
    For example, files and folders whose names start with "A" will appear before files whose names start with "B",
    but what about a list of characters for files and folders before the letter "A"?
    I'm doing some file organisation, and I need certain things to appear at the top of the list.
    I have noticed that the character-prefixes "0" and "(" seem to make things appear before "A"
    I would like a complete list if there is one available.
    Thank you!

    Pretty much any number or a space character. Punctuation does too, in theory, but I'd advise to limit it to hyphens and underscores. Periods are OK in the middle of file names but you won't be able to start a file name with one at the Finder level since that would actually hide the file.
    Matt

  • How can i send PGP encrypted file from PI to the receiver

    Hi experts,
                        I am unable to send the  PGP encrypted file from PI to the receiver. where the Clients sends the file using PGP encryption,
    But i am trying to send the same with PI. But i am not able to send the same can you please help me out to get the same incorporated using PI 7.1
    and sends to the receiver ( the rceiver would be FTP ).
    Regards,
    Amruth

    hi,
    You can write an adapter module to encypt your payload before sending to Reciever:
    /people/dijesh.tanna/blog/2008/09/15/sap-pi-integrating-macafee-e-business-server-with-sap-pi-70-for-pgp-encryptiondecryption
    http://www.bouncycastle.org/documentation.html
    http://www.cryptix.org/
    http://aedaptive.com/index.php/solutions/pgp-for-sap-netweaver
    http://www.pgpi.org/doc/pgpintro/
    PGP encryption: Do we need to write adapter module?
    If you are getting PGP file from sender and want  to send this file to target without any mapping transformation you can use this blog:
    /people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository
    Thanks.

  • How I can export files from CS5.5 to send for further editing in CS6 and no lose quality?

    how I can export files from CS5.5 to send for further editing in CS6 and no lose quality?

    If all you need for further editing is the contents of your Timeline,
    then you should follow Harm's sage advice.
    Lagarith Lossless Video Codec
    http://lags.leetcode.net/codec.html
    Ut Video Codec Suite
    http://www.videohelp.com/tools/Ut-Video-Codec-Suite
    But, if you will need all of your source media files to continue the edit,
    you should consider using the Project Manager.
    Trim or copy your project
    By using the Project Manager, you will be continuing the edit
    with the original media files and there will be no quality loss.
    Be aware that once you have edited the project in CS6,
    it will be problematic (but not impossible) to return to edit in CS5.5.

  • How to transfer rmvb files from pc to the new ipad?

    I just got the new ipad 3rd generation and this is my first ipad too.  How can I transfer rmvb files from PC to the new iPad?

    Rmvb files are Real media (yuck) files and are designed to be only playable in Real media player(ewww).
    They will not playback natively on the iPad.
    You must either convert them(good luck finding something that will handle that garbage) or use a third party player from the app store.

  • I just paid the $9,99 a month to have access to Photoshop and lightroom.  I am having trouble installing the programs and when I installed on Photoshop it said "trial"- this isn't suppose to be a trial but  a resource I pay for monthly for a year right?

    I just paid the $9,99 a month to have access to Photoshop and lightroom.  I am having trouble installing the programs and when I installed on Photoshop it said "trial"- this isn't suppose to be a trial but  a resource I pay for monthly for a year right?

    What turns the trial into the live software is signing in. If you sign in with the Adobe ID that has the subscription, the trial becomes live. First check your account on Adobe.com to make sure that the subscription is live.

Maybe you are looking for