Script to move files and compress

Hi Guys,
I am in need of a script that moves log files that are older than 14 days to a compressed folder. I would like to run this as a scheduled task that would run at the end of each week, and for the logs to go into the same compressed folder each week. Is this possible? And if so could anybody please help me? I have spent hours on this and I am really struggling as I dont have much knowlegde of scripting at all.
Many thanks,
Jack  

Ah my Friend we're in Powershell land for that, and very easy it is.
The compressing part is easy and does not require Powershell as long as the destination File system is NTFS
Make a folder called Archive (or whatever name suits you) and in Windows Explorer, go into the Properties of that folder, Choose the "Advanced Button" and select "Compress Contents to Save Disk Space" and hit apply.
Now you should see that folder change color.  Anything going into there is a compressed file.  The great part is you can view it like normal, it just uses far less disk space.   A Zip file might take even less but this is very easy to work with.
As far as accessing the log files older than 14 days, presuming the Folder is called C:\Logfiles and the filenames end with the extension .LOG
---------- Archive old Logfiles - Powershell Script -------------------
$TODAY=GET-DATE
GET-CHILDITEM C:\LOGFILES\*.LOG | Where { $_.LastWriteTime.AddDays(14) -lt $TODAY } | MOVE-ITEM C:\LOGFILES\Archive
---------- Archive old Logfiles - Powershell Script -------------------
All this does is look at the directory of files with the extension .LOG and check the last time the file was modified.  Anything older than 14 days is Moved to the Archive folder.   If the "Compression" attribute is enabled, there's your archive process :)
And of course if you don't have Powershell on the machine in question, it's a quick update from Windows to bring it in :)
Download Windows Management Framework - http://support.microsoft.com/default.aspx/kb/968929
Cheers
Sean
The Energized Tech
Powershell. It's so Easy and it's FREE!
Dive in and use it now, It'll take no time. :)
http://www.energizedtech.com
http://www.itprotoronto.ca

Similar Messages

  • What can I do to improve a blurry quicktime video that was SMS'd to me it is a 1.24MB .mov file and I have QuicktimePro. It was taken on an Iphone but I am not sure with what software.

    What can I do to improve a blurry Quicktime video that was SMS' texted to me? I think it was taken on an Iphone and it was sent to me as a 1.24MB .mov file and I have Quicktime Pro if that helps. I REALLY need to make this as clear as possible, the audio is good, video is blurry. Here is some additional data:

    anything I can even try? Sender is off the grid? I don't need a production ready copy just viewable?
    You can rescale (stretch) the size of the display but this will only make it blurier and/or introduce pixellation. When the file was encoded at a lower resolution much of the original data was thrown away to make the file smaller. This data is gone/missing and cannot be recreated from what is left. What you've got is all you have to work with. Any filters you can apply will require re-compressing the file again which will likely introduce more artifacts and increase the size of the file without really improving its overasll quality.

  • Hi apple users, I am in need of your expertise. I have a mov file and mp4 file which I need converted to DVD. However IDVD quality is terrible and wondering if anyone can help!?

    Hi apple users, I am in need of your expertise. I have a mov file and mp4 file which I need converted to DVD. However IDVD quality is terrible and wondering if anyone can help!?
    I created project in iMovie then exported it to MP4 and also MOV file at highest definition possible + I added it to iDVD and had a number issues about encoding errors regarding the mp4 file. MOV worked but the quality was terrible.....
    MOV file is as follows:
    4.08GB
    Codecs: H.264, ACC
    Colour Profile: HD (1-1-1)
    Dimensions: 1920 x 1080
    Duration: 12:33
    Audio Channels: 2
    MP4 File is as follows:
    3.02GB
    Codecs: H.264, ACC
    Colour Profile: HD (1-1-1)
    Dimensions: 1280 x 720
    Duration: 12:33
    Audio Channels: 6
    I have a MacBook Pro using the Yosemite system upgrade.
    I have updated iDVD and iMovie.
    I even bought the iSkysoft app from the mac store and that was terrible too.
    PLEASE HELP i am getting desperate and about to launch this macbook into the air
    2.66 GHz Intel Core i7
    Version 10.10. 2

    First of all, Hunt--thanks for responding!
    "First, where are you playing the MPEG-2, that you see that jitter?"
    On both a MacBook Pro, an Acer laptop and my Mac Tower. I would love to think that it is a problem with the playback system, and that if I merely send the file off to the duplicator they won't have the same problem. Maybe that is the case...I don't know if I have a choice rather than sending it off to see. But it happens in the same spots, in the same way, on all three of the players so I'm a little reluctant to have faith.
    "Another thing that can cause jitter in an MPEG-2 is the Bit-Rate - higher the Bit-Rate, the better the quality, but the larger the file. For a DVD, one is limited by the total Bit-Rate (both Audio & Video), but with longer prodcutions, some users choose too low a Bit-Rate. If this is the issue, one would need to go back to the original Project and do a new Export/Share."
    Of course, but in the case there is no more 'original project.' It is gone like the wind, stolen along with his computer and backups.
    I think I am stuck using one of two files as my master: a DVD he burned where I only see the stutter/vibration/jitter once, or the mpeg2 file where I see it three times. Hopefully, the duplication house can rip if off of one of them and not see the jitter. I know that in audio, my personal filed, you can do a lot to enhance already existing sound--EQ, compression, tape saturation emulation software, etc. I guess I'm hoping there is some kind of analog to the video world that address jitter after a source has been printed--if indeed the source has been printed to be jittery.
    Thanks,
    Doug

  • Songs show up as "QuickTime movie file" and won't share or sync

    I have a few mp3 audio files in iTunes that aren't being transferred to my iPod (3G) and aren't showing up when I share my iTunes library to another computer, and I can't figure out why.
    The filenames have ".mp3" extensions. When I do a 'Get Info' on them in the Finder, they're identified as "MP3 Audio File". Running 'file' on them from a Terminal window says "MP3 file with ID3 version 2.2.0 tag". They play just fine in iTunes as well as in QuickTime Player.
    But when I do a 'Get Info' on them from within iTunes, iTunes says each one is a "QuickTime movie file". And when I access this computer's shared music from iTunes on another computer on my network, everything shows up except these tracks; and when I sync my iPod, everything shows up except these tracks. I don't get any error messages.
    Why does iTunes think these songs are movie files, and how do I correct it?
    G5/1.8 Single   Mac OS X (10.4.8)  

    These files have the wrong creator.
    You can correct this by running the script on this web page.
    The page also contains information about avoiding this in the future.
    Hope this helps.
    M
    17' iMac 800 MHz, 768 MB RAM, 200 GB HD, DL burner   Mac OS X (10.4.8)   iTunes 7.0.1

  • Use Automator to move files and folder structure to another folder, retaining destination contents

    I have been struggling trying to setup Automator to move files and folder structure to another folder, retaining the destination contents.  Basically, I need to add files at the destination, within the same folder structure that exists at the source.  Here's some details about the scenario:
    -I have PDF files that I create on a seperate computer than I my daily use machine
    -For security reasons, the source computer doesn't have access to any shares on the destination computer
    -The destination computer has access to shares on the source computer
    -I want to delete the original PDFs at the source after they are moved or copied
    I haven't been able to get Automator to move or copy the folder contents (files and subfolders) without dropping everything copied at the top level of the destination, resulting in many duplicate folders and a broken folder structure.
    So far I've only had luck getting this to work at the command line, but I'd really like to have this setup in Automator so that I could have either a service or application that I could use for any folder, prompting for the source and destination folders.  I'm a relatively new Mac user with limited Linux experience, so this is the command that I've cobbled together and currently accomplishes what I'm looking for:
    ditto /Volumes/SMB_Temp/SOURCE ~/Desktop/Documents/DESTINATION
    cd /Volumes/SMB_Temp/SOURCE
    find . -type f -name "*.pdf" -exec rm -f {} \;
    Thanks for any ideas!

    If you have a command-line syntax that works, why not just create an Automator workflow with a single 'Utilities -> Run Shell Script' action, where that action has your (working) shell commands?
    Seems way, way simpler to me than trying to reinvent the wheel and transcribe shell commands into individual Automator actions

  • Writing a shell script to move files

    Hello,
    I'm trying to write a shell script that will move files from one directory to another at a time specified by me. I've got a similar script attached to an Automator action, which is triggered nightly by iCal.
    Of course, this one simply deletes files that are older than a day in a couple of locations. I'd like to have another that MOVES files and folders from one location to another. So far, I've come up with this:
    find /Volumes/Location/01/* -type d -or -type f -mtime +7 -exec mv -f /Volumes/Location/01/* /Volumes/Location/02/ ;
    Which just about works, but it actually seems to be moving all the files that are LESS than a week old. Any and all suggestions are appreciated, as I'm a total n00b here.

    find /Volumes/Location/01/*
    -type d -or -type f -mtime +7
    -exec mv -f /Volumes/Location/01/* /Volumes/Location/02/ ;
    Which just about works, but it actually seems to be moving all the files
    that are LESS than a week old. Any and all suggestions are appreciated,
    as I'm a total n00b here.
    your -exec is not selecting the files or directories found by the 'find' command.
    It is moving everything in /Volumes/Location/01/*
    Looking at "man find", I think you want your -exec to be
    -exec /Volumes/Location/01/{} /Volumes/Location/02/ ;
    As red_menace has pointed out, you have to change your -type options
    so that you select directories or files.
    You may also want to include -prune so that you do not decend
    into subdirectories.
    While the following is untested, I might write the command like this:
    find /Volumes/Location/01/*
    -prune -mtime +7
    ( -type d -or -type f )
    -exec mv -f /Volumes/Location/01/{} /Volumes/Location/02/ ;

  • HT1449 Can I just move my movie files and leave my music files where they are?

    Can I just move my movie files and leave my music files where they are?

    Yes, but bear in mind if you move the movie files, any files, from the iTunes media folder iTunes will not know where they are and therefore cannot access them. It will be up to you to tell iTunes were they are in order to use the files.

  • In Quicktime Pro I try to create a mov file and I get an error "-43 a file could not be found".  Any ideas?

    In Quicktime Pro I try to create a mov file and I get an error "-43 a file could not be found".  Any ideas?

    I have a similar problem which i did not have before...and it exists only in some powerpoint files which i want to print as a pdf file...and i get the same message as above.
    the log says the bellow details...what's the problem and how can i resolve it? thanks.
    %%[ ProductName: Distiller ]%%
    %%[Page: 1]%%
    %%[Page: 2]%%
    Cambria not found, using Courier.
    %%[ Error: invalidfont; OffendingCommand: show ]%%
    Stack:
      %%[ Flushing: rest of job (to end-of-file) will be ignored ]%%

  • When trying to move file and use command and drag, it doesn't move the file just creates a short cut.

    When trying to move file and use command and drag, it doesn't move the file just creates a short cut.

    Using command creates a copy.
    If you want to just move a file, click on it, hold it and drag it to the new location.

  • HT1014 I'm working with imovie 08 and converted movie originally from VHS tape to .m4v files imovie wouldn't recognize it.  I converted to .mov files and imovie generated thumbnails (for hours) and shows a New Event but there is nothing there. Any help?

    I'm working with imovie 08 on Macbook pro OS X and converted movie originally from VHS tape to .m4v files imovie wouldn't recognize it.  I converted to .mov files and imovie generated thumbnails (for hours) and shows a New Event but there is nothing there. Any help?

    markmc78 wrote:
    .. I'm really struggling with the concept of events/clips/projects.
    consider usage of a diff. editor.. iMovieHD6, you're entitled for a free downlaod at apple.com:
    http://www.apple.com/support/downloads/imovieHD6.html
    but IF you're relaxed, opened your mind, follow the bright light, ommmm.. for Events & Stuff:
    your intended workflow will add another step of quality-degradition (8mm>>avi>>mp4>>iM08) ..
    consider the free tool Mpeg Streamclip www.squared5.com for 'chopping' that 90min beast into pieces..
    rename these new chunks, follow advice given on my site:
    http://karsten.schluter.googlepages.com/im08changeeventdate
    there's the manual..
    http://manuals.info.apple.com/en/iMovie08_GettingStarted.pdf
    and the most recommended books from Mr Pogue's Missing Manual series..

  • To move files and Music on mp4 from an iMac to a external seagate drive 1T

    i can move files and music from the hard drive to the imac but i can't move them of the imac back to the external hard drive which is made by seagate i can't move my files or music from icloud to my external hardrive either, i have tried to download dropbox to help me but still no good can you help me please the hard drive holds 1T memory and i've had it about 2 years

    This is a forum for OS X Server software. You'll want to post this elsewhere.

  • HT3775 hello! I have downloaded a .mov file and it won't open in quicktime...any suggestions? Thanks!

    Hello! I have downloaded a .mov file and it won't open in quicktime...any suggestions? Thanks!

    get VLC player media
    it plays everything

  • Powershell move files and subfolders

    I can't try right now, but I think this will work (it will if you add the -force parameter that will create sub-folders if they don't exist)
    PowershellMove-Item -Destination "C:\aa_Mine\test\PowershellTest\testto\$dirname\$($_.directory.name)" -force
     For each moved object, it will store it into $dirname\
     

    Hello,Currently I have a batch script that moves files of a certain type from one folder to an archive folder with the current date. The script I use for this is:Batchfilefor /f "tokens=1* delims=" %%a in ('date /T') do set datestr=%%amkdir C:\ArchiveReportFiles\Archive\%date:/=%robocopy /E C:\eFinancials\report C:\ArchiveReportFiles\Archive\%date:/=% *.pdf /mov /minage:100 This works fine but it looks at the date modified not the date created so i still have files from over 2 years in there if somebody opened them by mistake, so I'm trying to recreate the the same script but using Powershell so I can use the CreationTime variable. I've got this:Powershell$dirname = "$((get-date).toString('dd-MM-yyyy'))"New-Item -ItemType directory -Path "C:\aa_Mine\test\PowershellTest\testto\$dirname"get-childitem -Path "C:\aa_Mine\test\PowershellTest...
    This topic first appeared in the Spiceworks Community

  • Can I store Movie files and other data on my Zen Xt

    My PC HD is full of movie files and I want to free up some space. Can I move these files onto my 60GB Zen Xtra?

    When transfering large files with the MTP firmware make sure you have the patch from Microsoft otherwise the file will not transfer back from the player to the computer.
    Get it here:
    <a href='http://support.microsoft.com/default.aspx?scid=kb;en-us;89536' target=_blank>http://support.microsoft.com/default.aspx?scid=kb;en-us;89536[/url]

  • Move files and create unique name something wrong with my script

    Can you see where I might be going wrong here?
    Just trying to create a unique name if something exists.
    In English.
    Move file to the destinationFolder
    Item exists in destinationFolder > Move file in the destination folder to the fake Trash > If it exists in fakeTrash too then give it a new name an ending of_a.psd then out it in the trash
    Once thats done move start file to the destination folder.
    Currently when the file exists in the destination folder and in the trash, I get the prompt then the error
    error "System Events got an error: Can’t get disk item \"NN_FR10WW06290PK3LE.psd\"." number -1728 from disk item "NN_FR10WW06290PK3LE.psd"
    set fileMatrix to {¬
              {folderName:"BHS", prefixes:{"BH", "SM", "AL"}}, ¬
              {folderName:"Bu", prefixes:{"BU"}}, ¬
              {folderName:"Da", prefixes:{"ES"}}, ¬
              {folderName:"Di", prefixes:{"DV"}}, ¬
              {folderName:"Do", prefixes:{"DJ", "RA"}}, ¬
              {folderName:"In", prefixes:{"GT", "CC"}}, ¬
              {folderName:"Fr", prefixes:{"FR"}}, ¬
              {folderName:"No", prefixes:{"NN"}}, ¬
              {folderName:"Ma", prefixes:{"MA", "MF", "FI", "MC", "MH", "MB"}}, ¬
              {folderName:"Pr", prefixes:{"PR"}}, ¬
              {folderName:"To", prefixes:{"TM15", "TM11", "TM17"}}, ¬
              {folderName:"Wa", prefixes:{"WA"}}, ¬
              {folderName:"Se", prefixes:{"SE"}}}
    tell application "Finder"
              set theHotFolder to folder "Hal 9000:Users:matthew:Pictures:HotFolderDone"
              set foldericon to folder "Hal 9000:Users:matthew:Pictures:Icons:Rejected Folder Done"
              set fakeTrash to folder "Hal 9000:Users:matthew:FakeTrash"
      ---here
              repeat with matrixItem in fileMatrix -- look for folder
                        set destinationFolder to (folders of desktop whose name starts with folderName of matrixItem)
                        if destinationFolder is not {} then -- found one
                                  set destinationFolder to first item of destinationFolder -- only one destination
                                  set theFolderName to name of destinationFolder
                                  repeat with aPrefix in prefixes of matrixItem -- look for files
                                            set theFiles to (files of theHotFolder whose namestarts with aPrefix) as alias list
                                            if theFiles is not {} then repeat with startFile intheFiles -- move files
                                                      try
      move startFile to destinationFolder
                                                      on error
      activate
                                                                display dialog "File “" & (name ofstartFile) & "” already exists in folder “" & theFolderName & "”. Do you want to replace it?"buttons {"Don't replace", "Replace"} default button 2 with icon 1
                                                                if button returned of result is "Stop"then
                                                                          if (count theLastFolder) is 0 thendelete theLastFolder
                                                                          return
                                                                else if button returned of result is"Replace" then
                                                                          set fileName to get name ofstartFile
                                                                          if exists file fileName indestinationFolder then ¬
                                                                                    try
      --next line moves existing file to the faketrash
      move file fileName of destinationFolder to fakeTrash
      move file startFile to destinationFolder
      --if it already exists in fake trash give it a new name then move that file to fake trash
                                                                                    on error errmess numbererrnum -- oops (should probably check for a specific error number)
                                                                                               log "Error " & errnum& " moving file: " &errmess
                                                                                               set newName to mygetUniqueName(fileName,fakeTrash)
                                                                                               set name of fileNameto "this is a unique name"-- or whatever
                                                                                               set name of fileNameto newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
                                                                else -- "Don't replace"
                                                                          if not (exists folder "Hal 9000:Users:matthew:Desktop:Rejected Folder Done") then
                                                                                    set theLastFolder toduplicate foldericonto desktop
                                                                          else
                                                                                    set theLastFolder to folder"Hal 9000:Users:matthew:Desktop:Rejected Folder Done"
                                                                          end if
                                                                          delay 0.5
      move startFile to theLastFolder with replacing
                                                                end if
                                                      end try
                                            end repeat
                                  end repeat
                        end if
              end repeat
              try
                        if (count theLastFolder) is 0 then delete theLastFolder
              end try
    end tell
    to getUniqueName(someFile, someFolder)
         check if someFile exists in someFolder, creating a new unique file name (if needed) by adding a suffix
              parameters -          someFile [mixed]: a source file path
                                  someFolder [mixed]: a folder to check
              returns [list]:          a unique file name and extension
              set {counter, suffixes, divider} to {0, "abcdefghijklmnopqrstuvwxyz", "_"}
              set someFile to someFile as text -- System Events will use both Finder and POSIX text
              tell application "System Events" to tell disk item someFile to set{theName, theExtension} to {name, name extension}
              if theExtension is not "" then set theExtension to "." & theExtension
              set theName to text 1 thru -((length of theExtension) + 1) of theName -- just the name part
              set newName to theName & theExtension
              tell application "System Events" to tell (get name of files of folder(someFolder as text))
                        repeat while it contains newName
                                  set counter to counter + 1 -- hopefully there aren't more than 26 duplicates (numbers are easier)
                                  set newName to theName & divider & (item counter ofsuffixes) & theExtension
                        end repeat
              end tell
              return newName
    end getUniqueName

    There are numerous errors in your script, and it's a large script so there might be more, but these are the standouts for me:
    At line 48 you:
                                                                          set fileName to get name of startFile
    which is fair enough - you then use this to see if the file already exists in the destinationFolder. However, if it does the logic about how to deal with that is flawed.
    At line 56 you catch the error:
                                                                                    on error errmess number errnum -- oops (should probably check for a specific error number)
                                                                                              log "Error " & errnum & " moving file: " & errmess
                                                                                              set newName to my getUniqueName(fileName, fakeTrash)
                                                                                              set name of fileName to "this is a unique name" -- or whatever
                                                                                              set name of fileName to newName
      --Now move the renamed file to the fake trash
      move file fileName to fakeTrash
      --now move the startfile to destination folder
      move file startFile to destinationFolder
                                                                                    end try
    so let's focus on that.
    56: catch the error
    57: log the error
    58: generate a new unique filename
    59: change the name of fileName to some other string
    Hang on, wait a minute.... we already ascertained that at line 48 you defined fileName as a string object that indicates the name of the file. This is just a string. It's no longer associated with the original file... it's just a list of characters. Consequently you cannot set the 'name' of a string, hence your script is doomed to fail.
    Instead, what I think you want to do is set the name of the startFile to the unique string. Files have filenames, and therefore you can set the name.
    You have a similar problem on line 64 where you try to 'move file filename to fakeTrash'. fileName is just a string of characters. It isn't enough to identify a file - let's say the file name is 'some.psd'. You're asking AppleScript to move file some.psd to the trash. The question is which some.psd? The one on the desktop? in your home directory? maybe on the root of the volume? or maybe it should search your drive to find any/all files with that name? nope. None of the above. You can't just reference a file by name without identifying where that file is. So you probably want to 'move file fileName of destinationFolder...'
    There may be other problems, but they're likely to be related - all issues with object classes (e.g. files vs. strings), or not being specific about which object you want.
    As I said before, though, I might be way off - you don't say where the error is triggered to make it easy to narrow down the problem. Usually AppleScript will highlight the line that triggered an error. Knowing what that line is would help a lot.

Maybe you are looking for

  • File sharing issues between iMac G5 20"/Mac OS 10.5.8 and iBook G3 600mhz/Mac OS 10.4.9.

    Both Macs can copy files from each other using the AFP connection.  However, I cannot copy files to another Mac.  So when I try and copy a file from the iMac to the iBook, I get these series of messages: 1) You May Need to enter the name and password

  • How do you recognize JLabel pictures when using mouseListener

    Im doing a project where im making parcheesi. for this project im using mouseListener and JLabel images on top of JPanel squares. I need to be able to be able to recognize each color in order to either move the image or to create a new one. Any point

  • "NoSuchMethodError" when using DOMParser

    Here's a real headache... much appreciation to anyone who can figure this out: I've installed the Winter '01 XML Pack on my NT box. To build a basic XML DOM program, I initially developed using a simple Java program running on the DOS prompt. No big

  • Deactivate volume license

    I am leaving my current job and need to deactivate the volume license of Creative Suite 3 that I have running on my home computer so it can be given to the new employee. There is no "deactivate" option under Help. What do I need to do to make sure th

  • Problems with sync between iphone 5 and macbook pro

    Never been able to sync macbook pro and iphone5. mac dosn't recognise it in anyway. done all normal stuff check for updates, deleted itunes through terminal and re-downloaded it. still no luck. iphone does sync with other laptops. and the usb port on