How to return files after replacement. How to return a file to its previous version. Backup and cloud services

I need to copy all *. doc files(but not folders whose names match *.doc) from network folder\\server\source (including files in all subfolders) in local folder C:\destination without preserving subfolders of the hierarchy (i.e. all files should go directly to C:\destination and no subfolders should be created in C:\destination). If there are several files with same names from different subfolders of \\server\source , only the first one should be copied and never overwritten - all conflicting files found later should be skipped (there may be many cases like this and skipped files should not be transferred over the network, otherwise it will take too long). Here's my attempt to implement it in PowerShell:

Cp \\server\source\* -Recurse -Include *.doc -Container:$false -Destination C:\destination

There are two problems with this command:

  • It copies folders whose names also match *.doc.
  • In case of conflicting names, any file found later is transferred over the network and overwrites the previous file.

Can you suggest how to fix these problems?
Implementations using copy , xcopy , robocopy , cscript or *.bat , *.cmd are also welcome.
The local OS is Windows 8 and the file system is NTFS.

5 answers

I'll first create a list of files and check how you go through the list.

Something like that:

$srcdir = "\\server\source\"; $destdir = "C:\destination\"; $files = (Get-ChildItem $SrcDir -recurse -filter *.doc | where-object (-not ($_.PSIsContainer))); $files|foreach($_)( if (!(::Exists($destdir+$_.name)))( cp $_.Fullname ($destdir+$_.name) ); )

So, use Get-ChildItem to display the files in the source folder matching the filter via where-object to cut out the directories.

Then go through each file in a foreach loop and check if the file name exists (not full name) on the target using the Exists method of the system.io.file .NET class.

If this is not the case, copy using only original name file (discarding the original path).

Use the -whatif option on the copy when testing, so it only displays what it would do, in case the result is not what you wanted :-)

The previous answers seem too complicated to me if I don't understand something. This should work:

Get-ChildItem "\\server\source\" *.doc -Recurse | ?(-not ($_.PSIsContainer -or (Test-Path "C:\Destination\$_"))) | Copy-Item -Destination "C:\Destination"

None of the built-in commands - copy, xcopy or robocopy - will do what you want on their own, but there is a utility called xxcopy that will be conveniently available at http://www.xxcopy.com. It has a number of built-in options specifically designed for flattening directory trees into a single directory. Below is what you described:

Xxcopy "\\server\source\*.doc" "C:\Destination" /SGFO

# Get all *.doc files under \\server\source Get-ChildItem -Path \\server\source *.doc -Recurse | # Filter out directors Where-Object ( -not $_.PsIsContainer ) | # Add property for destination Add-Member ScriptProperty -Name Destination -Value ( Join-Path "C:\destination" $this.Name ) -PassThru | # Filter out files that exist on the destination Where-Object ( -not (Test-Path -Path $_.Destination -PathType Leaf ) | # Copy. Copy-Item

Why use foreach when you already have a pipeline? Computed properties for the win!

Get-ChildItem -Recurse -Path:\\Server\Path -filter:"*.doc" | Where ( -not $_.PSIsContainer ) | Group Name | Select @(Name="Path"; Expression=($_.Group.FullName)),@(Name="Destination"; Expression=("C:\Destination\(0)" -f $_.Name)) | Copy-Item

Pavel Mikhailov

When Apple company introduced Leopard with a feature that allows you to restore personal files users deleted at various points in time were all in awe. Many people still do not know that Windows Vista also has a similar feature, in it you can also restore deleted files or their previous versions.

How it works

The Microsoft Vista operating system allows you to restore deleted or previous versions of files and folders through the use of special recovery points that are created by the System Restore service. This service, using information from the last created recovery point, allows you to get back some deleted or replaced data.

The service uses some of your free space to store recovery points. hard drive. The points are overwritten as this volume is filled. Larger number points accordingly takes up a larger volume. You can manually adjust it, but at a minimum you need at least 300MB. Anyway system recovery will not take up more than 15% of the total capacity of your hard drive. It should also be noted that the service does not work on drives with file system FAT32.

Check availability on your hard drive free space to 300MB and then enable the system recovery service or make sure it is enabled. To do this, follow these steps:

  1. Click the "Start" button;
  2. Select "Computer", click on it right click mouse and select "Properties";
  3. Login to " Extra options System" and then select the "System Protection" tab;
  4. A check mark next to the drive indicates that system recovery is enabled for it. Check the boxes for all required disks or partitions.

In our case, recovery is enabled only for drive C.

Once you have enabled System Restore, it is recommended that you manually create a restore point. To do this, you don't have to restart your computer, just follow these steps:

You don't have to do this all the time. After you have enabled System Restore, Windows Vista will automatically create a restore point every day. Also, a restore point is created in case of each system event, for example, when installing a program or driver.

Now you can recover your deleted files and folders. Please note that the sooner you enable system recovery, the more likely you are to recover your data. It is almost impossible to recover a file deleted before the service was enabled. You can only try to do this using various recovery programs, and even then only if other data has not yet been written to the place of your files.

After this, your recovered files and/or folders will appear in the place where you dragged your data.

If you forgot where your deleted file or folder was

If you forgot where your deleted file or your remote folder, then you can simply select the disk on which they were located and, right-clicking on it, go to its “Properties”, and then to “Previous Versions”.

Excel file recovery is usually required after an unexpected power outage or due to computer system errors. In Excel 2007 and other versions, you can restore unsaved files and their previous versions. Exist various ways backup data to your PC, which will help you avoid similar troubles in the future. Wherein third party programs will not be needed to restore files.

A situation may arise where you are working on a very important document for several hours, creating very complex schedule. The file may become corrupted due to a power failure or the user simply forgets to save it. This is not a reason to despair, since it is possible to recover XLSX files. The worst case scenario that can occur is when you know that you made a mistake in the calculations, but then corrected the error. If you try to restore Excel file, then you may end up with a version that contains an error. Recovery deleted files- this is also a serious problem.

AutoSave and AutoRecover

If you are interested in how to recover data for free in Excel 2003, 2007 or more later version program, the application provides users with useful features such as AutoSave and AutoRecover. If they are enabled by default, then you will not have any difficulty in recovering XLS files. However, users often misunderstand how these functions work, so first you need to decide what they are.

AutoSave option in Excel automatically saves new document, which the user has just created, but has not yet saved. This will help you avoid losing important data if the power is turned off or system error. Excel's AutoRecover option helps you retrieve unsaved files after accidentally closing a document or crashing. This feature allows you to restore the last saved version, which is displayed in the Document Recovery panel the next time you start the program.

The AutoRecover option only works with Excel documents, which have been saved at least once. If you never saved a file before your computer crashed, the Document Recovery panel will not appear in the application. Fortunately, recovery options damaged files enabled by default. If you are not sure whether they are enabled, you can easily check.

How to configure autosave settings

To configure AutoSave settings, follow these steps:

  • go to the File tab and select Options from the menu;
  • click Save in the left panel of the Options dialog box;
  • you need to make sure that the file is saved every few minutes, and if the application is closed, the latest automatically generated version remains;
  • click OK.

By default, the recovery program is set to automatic saving changes to your document every 10 minutes. You can shorten or extend this interval at your discretion. You can also change the location of the AutoRecover file. If the likelihood of a system failure or power outage is too high, you need to reduce the time interval for storing information. The more often a document is saved, the more versions of the file you will have. As a result, the chances of recovering information will increase many times over. Now that the program is set to automatically save and recover damaged Excel files, you can easily get your data back if something goes wrong. We need to figure out how to restore new files that the user just created, and those that were saved manually.

How to recover unsaved data

A situation may arise when you are working on a new document in Excel, and the program unexpectedly closes before the file is saved. In this case, there is no need to panic because the data can be recovered. Restoring Excel files will require the following steps:

  • go to File, Open;
  • select Recent Workbooks;
  • scroll down and click the Recover Unsaved Workbooks button at the bottom of the list;
  • alternatively, you can go to File, Info, open the Manage Workbooks drop-down list and select Recover Unsaved Workbooks;
  • when the dialog box opens, select required file and click Open.

The document will open in Excel and the program will prompt you to save it. Should be pressed Save button As on the yellow bar above the sheet and save the file in the desired location.

Recovering Overwritten Data

The Excel application not only allows you to return unsaved documents, but also restore previous versions. This is especially useful when the user makes a mistake that they cannot undo. The function is also useful if you need to see what a document looked like a few minutes ago.

To recover an overwritten Excel file, you need to go to the File tab and select Info in the left pane. Next to the Manage Versions button, you will see all the automatically saved versions of your document. The program automatically saves versions at certain intervals, but only if you have made changes to the table between these intervals. Each version title contains the date, time, and note. If you click on any of them, it will open along with the latest version document so that the user can compare and see all the changes.

If the program was closed incorrectly, the restored information will be called When I Closed Without Saving. If you open this file through Excel, a message will appear above the document. Simply click the Restore button on the yellow bar to return to the new, unsaved version. The application deletes all automatically saved versions when you close the document. If you want to view again previous version, then it is better to back up your data.

How to create a backup

Automatic backup copy excel- this is very useful feature, which can help you restore a previously saved version of a document. Creation backup copy will help return the user his work if accidentally saved unnecessary changes or deleted original file. As a result, the current information will be saved in the original document, and the previous one will be saved in the backup copy.

This feature is very useful, but quite difficult to find in Excel. To do this you need to do the following:

  • go to File section, Save As;
  • select Computer and click the Browse button;
  • when the Save As dialog box opens, click the small arrow next to the Tools button at the bottom of the window;
  • select General Options from the drop-down list;
  • select the Always Create Backup checkbox in the General Options dialog box and click OK.

Now you can rename your file and choose the desired location to save it. Excel program will create a backup copy of the document in the same folder. The backup is saved with a different extension (XLK). The app will ask you to confirm your decision before opening it. Just click Yes to restore the previous version of your table.

Create a time-stamped backup

The backup restore function may not be enough. Every time you save a document, new copy replaces an existing file. How can you get back to more early version, if the document has already been saved several times? There are at least 2 ways out of this situation. First of all, you can use ASAP Utilities. Such a recovery utility offers the user a tool to create multiple backups. After installing ASAP Utilities for Excel, you will be able to use special combination keys for saving documents and automatic creation backup copies for the purpose of subsequent restoration of damaged files. Each version will have a label in the file name, making it easy for the user to find necessary copy, guided by the date and time of its creation.

If you know how to use VBA, you can use a special Excel macro AutoSave for file backup. Just copy it and paste it into a code module. The user will be able to create as many backup files, as much as he wants, and for this it will be enough to click on a special shortcut. As a result, previously saved versions will be restored, but old file the backup will remain unchanged. Each copy is marked according to the date and time it was created.

Backup and cloud services

If instead of a flash drive you use to store documents cloud online services, then restoration Excel data won't be a problem. For example, you can use OneDrive − cloud storage from Microsoft. The advantage of this service is that it is closely related to Office package. You can quickly open and save documents to OneDrive right from Excel applications. Sharing These programs allow you to quickly synchronize documents and share files with other users through a shared folder.

When one user makes changes to a document, OneDrive automatically saves different versions, so you don't have to keep multiple copies of the same file for fear of them being deleted. You can see earlier versions in the version history. In this case, you can find out when the document was changed and who made the adjustments. The user can restore any of the previous versions.

Another very popular service for cloud storage is Dropbox. It saves all changes to Dropbox folder for the last 30 days. Even if you make incorrect changes, the file becomes damaged or is erased, you will be able to recover more old version deleted document with just a few clicks of the mouse button. Dropbox service doesn't work with Microsoft Office just as tight as OneDrive, but easier to use when recovering damaged data.