Script for moving files and directory to archive

Hi,
I've search the web for good working script to archive my files and folder with no luck.
do you have a script that move and preserve the structure of older files and folders that have not been accessed for X days?

Hello, I found this quite quickly in the TechNet Gallery. It seems like it would do what you're looking to do.
https://gallery.technet.microsoft.com/Archive-old-files-with-042f859a
# Powershell script - move old files to an archive location.
# Writes log files to $logpath
# Ver 0.6
$path = "C:\TEMP"
$archpath = "D:\TEMP-ARCH"
$days = "30"
$logpath = "C:\Temp"
$date = Get-Date -format yyyyMMddHHmm
write-progress -activity "Archiving Data" -status "Progress:"
If ( -not (Test-Path $archpath)) {ni $archpath -type directory}
Get-Childitem -Path $path -recurse| Where-Object {$_.LastWriteTime -lt (get-date).AddDays(-$days)} |
ForEach { $filename = $_.fullname
try { Move-Item $_.FullName -destination $archpath -force -ErrorAction:SilentlyContinue
"Successfully moved $filename to $archpath" | add-content $logpath\log-$date.txt }
catch { "Error moving $filename: $_ " | add-content $logpath\log-$date.txt }

Similar Messages

  • Need script for moving files to specific directories base on csv

    Hi,
    I have a question. I have about 2000 files (pdf), which I need move to specific directories and subdirectories, which are based on csv file.
    Csv is looking like this:
    filename;directoryname;subdirectoryname;subdirectoryname;.......etc.
    I have a script for creating directories with subdirectories from csv file, but I need this script for moving files to this directories.....
    Thanks a lot for every help.
    Best Regards
    Petr, OS X Mavericks

    private function snapshotLastFrame():void
    gotoAndStop( this.totalFrames );
    _bitmapData                         = new BitmapData( stage.stageWidth, stage.stageHeight );
    _bitmap                              = new Bitmap( _bitmapData );
    _bitmapData.draw ( stage );
    saveImageJPG( _bitmapData, "test.jpg", 96 );
    public function saveImageJPG( bitmapData:BitmapData, fileName:String, quality:int ):void {
                this.jpgEncoder = new JPGEncoder( quality );
                this.fileReference = new FileReference();
                this.fileReference.save( this.jpgEncoder.encode( bitmapData ), fileName + ".jpg" );
    Keep in mind that you need a few extra libraries to be able to create a jpeg.. (AS3CoreLib) can be found at googleCode.

  • A script for moving files to folder ? or relaunch photoshop

    I'm looking for a very simple java script to check file corruption
    it should:
    1.open a file I send to it (via droplet)
    2.if it works > close the file > send the file to a folder like c:/checked/
    3.if the open sequence crashes or doesn't work > re launch photoshop
    4.mark the file as beeing corrupt or send it to a another folder
    I don t know how to move a file via java script without saving
    I don t know how I can relaunch ? force-quit photoshop ? is this even possible ?
    Regards

    Anstellos1 wrote:
    xbytor2 > thats the exact problem I'm having. If there is a "wrong" file into my batch, photoshop stop/ crash, is waiting for an action on my side... the whole idea of using photoshop droplets is to do it without me.
    Should I parse the files (I have jpegs; png and raws... parsing raws ?)? Would it be better like someone said to use a script that "try catch"? (no idea what it is or how to write this). I also red that photoshop image processing is skipping bad files, is that true ? how could I apply this technique ?
    bad file > skip > no crash > process continue running would be even better than the original validation idea
    "Unfortunately, there are types of jpeg corruptions that cause PS to  throw up a 'Broke File' dialog in spite of how you open the file or have  your DialogModes preferences set. PS just stops cold waiting for user  interaction. I'll see if I can locate one of these that I used to test  with. The last time I looked at this problem in depth (CS2 or CS3) PS  was still misbehaving.
    xbytor2 if much more of an expert than I am in the script area so will have to defer to him"
    I would have to defer to xbytor2 since he is much more of an expert than I in scripting.  If the Try....Catch construct does not work, than Image Processor in PS and also accessed by Bridge would fail under the same circumstances since that is the construct  that script uses.  Interesting
    "How would you write that ? Are you saying that if I use this script  at the beginning of my photoshop droplets, it won't crash on a bad file and continue looping on the next ?:"
    If you want to use the Try...Catch constructs looking at the Image Processor Code from ExtendScript ToolKit (or other script editor) would let you see how it operates.  They use the Try...Catch construct in multiple locations in that script.
    At the highest level in Image Processor here is the basic code below for the Try...Catch construct with most everything else stripped out.
    There are two main steps. One is to set the app.displayDialogs mode to NO. The second is to use the try...catch construct below.   The error routine is the catch portion of the code just displays the error code.  Then the dialog mode is reinstated to the original settings set by the User.   The same construct is used deeper into the code so that would be a source of at least the approach Image Processor uses.
    try {
        // remember the dialog modes
        gSaveDialogMode = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        Code you want to execute goes here
    // Lot's of things can go wrong
    // Give a generic alert and see if they want the details
    catch( e ) {
        if ( e.number != 8007 ) { // don't report error on user cancel
            alert( e + " : " + e.line );
    // restore the dialog modes
    app.displayDialogs = gSaveDialogMode;

  • Moving files and folders in the Library module

    I teach a lot of LR users and one area that's consistantly frustrating and unintuitive (even to some experienced users) are the rules for moving files and folders around in the Library module. I'm not sure I have all the right answers/suggestions/remedies but here are the basic points worth examining:
    1) Additional hard drives aren't listed unless images from it have been imported into Lightroom. It would be nice if people could add a new hard drive without importing files from it. People don't get it that you can select "Add Folder" from the Folders pop up menu. Classic example: Say someone has purchased a new hard drive for archiving purposes. It's empty and they want to drag folders of images onto it from within LR. Possible Solution: include a "Add Drive..." option from the Folder's panel + pop-up menu that would behave the same and add a root level folder.
    2) One can't drag more than one folder at a time. While I assume this is designed to prevent accidental mass movement it would be nice if one could enable the movement of multiple folders. 
    3) One can't drag a folder onto the main drive bar that lists the drive's name and capacities - one has to drag onto a folder within a drive. I'd love to be able to drag a folder onto the root level of a drive by dropping onto the drive bar (this would be similar to the MacOS finder).
    4) Sometimes the root level of a drive isn't apparent. One may need to right click on a folder and select "Show Parent Folder" to show the root level folder which is named after the volume. Showing a root "folder" that has the same name as the drive is also confusing to people since there isn't actually a folder on the hard drive with that name.  I completely understand why folders are hidden by default and I'm not sure the remedy is but, again, this isn't intuitive for new users. If #3 worked as described perhaps we could have root level access without the root folder?
    Scott Martin
    www.on-sight.com

    Perhaps I should add that I really like and appreciate a lot of the decisions that have already been implemented into the Library's Folder's tab. Moving files instead of copying them, showing only folders that contain imported images, the ability to show or hide parent folders.... Bravo!

  • File and Directory Maintenance on OSX Server

    Are there any special considerations for using file and directory maintenance utilities such as Disk Warrior or TechTool, etc. when dealing with OSX Server, or can it be handled just like any other volume.
    We have all of our data and our user home directories on the server and I would like to run some miantenance on them.
    Thanks.

    I am no expert on disk utilities.
    Personally, I just have a separate 5G partition with a minimal OSX which I boot from once a month (or before a server update) and run Disk Repair & Repair Permissions from.
    As far as I know, there is nothing going on on the server that is not going on on a 'normal' OSX machine (at file level mode). The OSX unix offering is miles from the previous OS9 model where the likes of Norton was almost mandatory. The built-in 'periodic' scripts and disk utility 'repair' (see "man fsck" in Terminal) all run at unix level, and have done for years, even before Apple II days!
    Although I have both Disk Warrior & TechTool, I don't use them except in an 'emergency' (otherwise called: "try anything").
    I would be interested in any other comments though.
    -david

  • File and directory names with Danish characters

    I have installed the Novell Client v2.0 for Linux on my Open Suse 10.3. The Client is connecting to my Netware servers (6.0 & 6.5) without any problems...
    There is one problem... Filenames and directory names with the Danish , & (ae, oe & aa), e.g the filename bger.doc (bger = books) is shown as b. and when clicking the file the file disappears from the file list. It seems to be the same problem with the German (umlaub).
    What to do?
    /Michael

    Originally Posted by J.H.M. Dassen (Ray)
    mimo <[email protected]> wrote:
    > There is one problem... Filenames and directory names with the Danish ,
    > & (ae, oe & aa), e.g the filename bger.doc (bger = books) is shown as
    > b. and when clicking the file the file disappears from the file list. It
    > seems to be the same problem with the German (umlaub). What to do?
    As far as I know, the Novell Client for Linux expects that file and
    directory names use the UTF-8 encoding and does not support a traditional
    8-bit encoding like ISO 8859-1. Try changing the encoding of file and
    directory names to UTF-8 as described in
    SDB:Converting Files or File Names to UTF-8 Encoding - openSUSE
    HTH,
    Ray Dassen
    Technical Support Engineer, EMEA Services Center, Novell Technical Services
    Novell, Inc. Software for the Open Enterprise Software for the Open Enterprise
    Seems a good hint. When I create a folder or file from within SUSE using an "Umlaut" everything is OK and NCL 2.0 displays them correctly as they are UTF-8 formatted.
    The proposed tool is no solution: one cannot convert folders or files that one cannot see (does it work for folders at all?). Maybe a windows tool would work because one could search for all files or folders with "Umlaute" and convert them. Other options?

  • Wait for a file and start execute a scenario process

    What is the best way to achive: Wait for a file and then once the file in droped...execute a scenario process.
    Sample scenario:
    - Admin user ftp the file to a target directory on Unix (export/home/odi/input/files)
    - A scheduled scenario package will be running/scheduled daily
    - In the above scenario, The first step is to have one OdiFileWait (with options: Dir:/export/home/odi/input/files, File: xxxxx.txt,wait time and loop over..etc)
    /* But for some reason OdiFileWait is not waiting/checking for the file presence define in the option. It seems to run immediately without checking the presence of the file and passing it to run the second step) */
    - The second step is the "OdiStartScen" (This will run an interface generated scenario) and since the file doesn't exist as a source to load that this interface uses...its fails.
    What's the common practice to accomplish this? Appreciate your feedbacks…
    Thank you

    Update:
    I increased the timeout and Pollint setting in OdiFileWait option and its working fine now.
    When the file exists (or) ftp within the timeout the process goes to next step (OK). But, say the file doesn't exists and the timeout finished...how do i set a KO to OdiFileWait and stop/complete by existing at that step itself with out failure.

  • 8dot3 filenames not created for Program Files and Program Files (x86)

    Interesting issue we are realizing on Servers deployed from SCCM 2012. 8dot3names are not created for Program Files and Program Files (x86). they are created for other files/folders at the root of C and below Program Files and Program Files (x86). This is
    causing issues when programs are installed and the path is then created with 8dot3 filenames for program files and program files (x86)

    Arg. we just got bitten by this "feature", and it's affecting our security software stack (name starts with M and ends with ee), and some ancient crud too.
    And found this, which suggests a logical reason for 8dot3name to not be present on servers, but, on clients, I think it's a rather gross assumption...
    http://blogs.technet.com/b/josebda/archive/2012/11/13/windows-server-2012-file-server-tip-disable-8-3-naming-and-strip-those-short-names-too.aspx
    Don
    (Please take a moment to "Vote as Helpful" and/or "Mark as Answer", where applicable.
    This helps the community, keeps the forums tidy, and recognises useful contributions. Thanks!)

  • File and directory permissions

    We are running OSX 10.7 Lion on a Mac Pro 1,1 IN RAID. We are using this system als fileserver. Since last year it came to our attention that there where problems with the permissions on the files and directories (they seem corrupted). I do not mean system files but the files we stored on this server. When I look at random file permissions I get a whole list of users etc. A lot of duplicate users are there and also there are some entries in the list saying 'fetching'.
    We use the server admin tool to manage groups and users.
    This is what we have done so far:
    - Try to repair permissions through terminal (because of RAID configuration)
    - Propogate permissions through server app
    - Resetpassword trick (restart cmd+R / terminal / resetpassword)
    Can anyone tell me how to get this working 'clean' again? is there a way to reset all files according to the workgroup/user settings in the server app?

    Sounds a bit like the temp files are not being 'closed' after being written
    to or read by Labview. If you are using the advanced file vi's make sure
    that they are closed afterwards.
    If the OS assumes they are open then it will not allow deletion etc even
    outside of Labview.
    bubucis wrote in message <7kv2kl$3flk$[email protected]>...
    >Hello!
    >
    >Does anybody know how Labview deals with file and directory permission
    >locking under WinNT.
    >I have a following problem. There is a main VI running in a state machine
    >mode and it fires up a SubVI that has a bunch of SubVIs. One of these
    >SubVIs are creating a temporary directory and files that I want to delete
    >once everything is over. However I always get a file permission error when
    >trying to delete those f
    iles, also when using Explorer and trying to delete
    >those files I get a file sharing error. This happens even when main VI has
    >been stopped. How comes LabVIEW does not unlock that file and directory.
    >Rather annoying!
    >Thanks for you help.
    >
    >Reinis Kanders
    >
    >

  • Shortcut for moving forward and backward through Time Machine

    It seems obvious that there should be keyboard shortcuts for moving backward and forward through time in the Time Machine. Anyone know how?

    V.K. wrote:
    it might seem obvious but AFAIK there are no shortcuts for that. use the mouse.
    I can't imagine replacing a simple mouse click with something like
    Cmd-Ctl-Shift-Fn12-page up
    It's noticeable that the menu disappears when entering TM, meaning that the usual assignments of shortcuts in the KB menu have, at least for the present, unknown values, if any at all.
    What kind of shortcut would take me back to December 25, 2007 anyway? The trackpad and trackpad bar work.
    It's possible to open TM with a shortcut or script, but from there one is on the dark side.
    Message was edited by: nerowolfe

  • Attachments dont download from Gmail in Safari, They disappear,I even tried re-downloading Safari and that download disappeared, it is not in my downloads folder, I actually searched in finder for the file and it is nowhere on my computer.  Please help!

    Attachments dont download from Gmail in Safari, They disappear,I even tried re-downloading Safari and that download disappeared, it is not in my downloads folder, I actually searched in finder for the file and it is nowhere on my computer.  Please help!

    Oh my gosh I had the EXACT same problem, and for ages I couldn't figure out how to fix it until today. Here's what I did:
    First I went onto my computer, opened itunes, and un-installed tumblr, vine and kik. These were the apps I was having problems with (it said I had them on my phone but, like you, they didn't show).
    Then I went to the itunes store, searched for each one, and it said I could update them so I did (just FYI: for tumblr a window popped up saying "please click ok to confirm you are 17 years or older", so I did that also)
    When I went back to my phone and tried installing them again (still on my computer), it worked!
    I hope this helps, because it was incredibly frustrating. Good luck!

  • Searching for missing files and damaged photo icon

    I am trying to view photos that I have viewed in this program numerous times before but now when I click on the photos, I get a message that says "searching for missing files". Sometimes, the photo appears with a red icon below it that resembles a wripped photo. Does this mean my photo has been damaged by the program?

    I too have been told to find them on my hard drive but still nothing comes up, I can find the picture name and then do a search, but nothing. I've tried several times and it just keeps saying seach for missing files not found. I can see my collection of pictures, but there blury and then when I try to click on them, it says searching for missing file and it gives me the file name, and then I've tried to go under my search and put that file name in and nothing comes up, I also got NO help from adobe and they want us to buy more products??? They could have warned us somehow on what happens if you move them or try and put them on disc, and that's what happen, I put some on disk or at least thought I did and then realized I didn't want to do that, so I hit the UNDUE and I guess it was so late or something, cuz I can see the pictues, just can't open them. I'm wandering if I need to have a expert see if he can get them off of Adobe, I really want the pictues I have graduation pictures on there and need them very much. Would love to have help from anybody. Please.
    Thank you
    K

  • The specified file or folder name is too long,the url path for all files and folders

    The specified file or folder name is too long,the url path for all files and folders must be 260 character or less
    can we increase this limit?
    MCTS,ITIL

    Hi,
    As I understand, you want to increase the length of URL path in SharePoint 2010.
    Per my knowledge, this limit cannot be increased. SharePoint limits URL length because all relative URL links are stored in the clear forms on the SharePoint content DB and often this links are used as primary keys to link one table with another. Fields
    which are used to store these links (for instance tp_DirName from the AllUserData table) allow storing only 256 characters.
    There are several ways that you can resolve or mitigate URL length problems in the SharePoint Server 2010 environment. The following list provides suggestions:
    1. Upgrade all the end-user browsers to Internet Explorer 8, which has a longer URL length limit.
    2. Use shorter names for sites, folders, and documents and control the depth of the site and folder structures to reduce the lengths of URLs.
    3. If possible or allowed, use ASCII names for sites, folders, and documents. This will avoid situations where the URL will be lengthened by being encoded.
    4. To reduce the risk that the SharePoint Server 2010 end-users will encounter problems because of URL length limitations, we recommend that you apply the following effective limits in the deployment:
    256 Unicode (UTF-16) Code units - the effective file path length limitation, including a domain/server name
    128 Unicode (UTF-16) Code units - the path component length limitation
    More reference:
    http://technet.microsoft.com/en-us/library/ff919564(v=office.14).aspx
    http://sharepointknowledgebase.blogspot.in/2013/04/url-path-length-restrictions-in.html#.VKJN53BJA
    Best regards,
    Sara Fan

  • Shell script for moving and renaming files

    I'm not so familiar with shell scripts. I have created some simple scripts for various tasks but now I hit something I can't handle myself.
    My server receives every night a logfile from another server. This file I need to rename and move to another location. Problem is that a simple mv with new filename isn't enough, I need to insert date in filename. Format for date should be ddmmyy. Also the name of incoming file changes every night. The output always starts with same letters, let's say "log", and the date is used to identify files.
    For example I receive a file /Input/filename.log and I need to move the file to the folder /Output with name log130308.txt.
    Any tips how to insert the date as part of of filename while renaming or moving the file? I prefer shell script as I'll use launchd for scheduling the script.

    Hi again,
    so far I've constructed this:
    cd /input
    for file in `ls *log`
    do
    echo "Copying " $file
    cp $file /output/log.$file.`date +%d%m%y`
    done
    Quite there. I'm cding to directory, i'll focus later how to set some environmental parameters.
    Problem with zipping is that I don't know exact logfiles names. Each day there's a new name. So zip -q filename.zip filename.log isn't quite enough and it's impossible to use wildcards. The switch -q and checksums were welcome suggestions.
    Thanks again,
    Juha
    Message was edited by: J.Otava

  • Moving file from Target to Archive Directory

    Hi All,
    My Scenario is that we have a .txt file in Target directory in SAP PI (AL11) and when an arching Script is run this file is moved from Target folder to Archive Folder and also uploaded in R3.
    Now the requirement is that the file is transffered from Target to Archive folder without being processed.Now the user want the file back in Taget folder from Archive Folder also user also wants to know who has run the Script.
    Please let me know how to put file back from Archive to target folder and check the log as who Run the Script.
    Regards,
    Nidhi

    Hi Nidhi,
    I think i am not getting your question
    >>when an arching Script is run this file is moved from Target folder to Archive Folder and also uploaded in R3.
    Now how the script is run? using OS commands of File adapter or by some other means
    >>Now the user want the file back in Taget folder from Archive Folder also user also wants to know who has run the Script.
    For getting it back in Target folder, you can manually copy it. Also to see who has done this you need to check how the scripts run. If it runs as a standalone one then you need to see whether in the system you have some log files of the run. If file adapter runs this scripts then check the Communication channel monitoring log (BTW it if was File communication channel which invoked this Scripts then the message would have sent to PI. Need to recheck that too)
    Regards
    Suraj

Maybe you are looking for

  • Performance issues with FDK in large XML documents

    In my current project with FrameMaker 8 I'm experiencing severe performance issues with some FDK API calls. The documents are about 3-8 MBytes in size. Fortmatted they cover 150-250 pages. When importing such an XML document I do some extensive "post

  • Unable to update my  iOS on my iPad and iPhone.

    I am unable to update my iOS on my iPad and iPhone. Though I have had these devices and have been updating for over a year, the issue just started with this new release (iOS 5.1). When I connect my Pad and Phone to iTunes (Windows PC with Vista), I a

  • Macbook air speaker not working

    I recently discovered that the right speaker to my Macbook Air isn't working... I've tried: checking sliders in Sound System Preference checking MIDI Utility zapping the PRAM resetting all prefs (using Onyx) removing the bottom to look for a loose co

  • [Table access] RFC with XML

    Hi everyone, The idea is to be able to read/write a table in the backend system (would it be R/3 or BW) from the Visual Composer. In a first attempt, I managed to do it by creating 2 RFCs: one for reading the table, another for modifying it. It works

  • Define Clearing Accts for Payment Diff. with Altern.Currency

    Dear SAP Gurus, Please suggest difference between Define Clearing Accts for Payment Diff. with Altern.Currency & Define Accounts for Payment Differences with Altern. Currency. I am not able to understand what the use of defining Accounts for Payment