Recovering files after overwriting. How to copy specific files (without folder hierarchy) but not overwrite existing files

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 the FAT32 file system.

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 yours 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”.

File History utility ( File History) in Windows got its name for its ability to restore older versions of a file. This feature is part of all programs Reserve copy, although it is often called "Restore". Although the idea is the same: from the backup archive you remove old version file. The File History feature makes it easy this process and working with files in general.

In order to return the old version of the file from backup disk, you need to follow these steps.

  • If need to replace current version new: select "Recover" and then "Replace file in target application." The current file is replaced by the backup copy.
  • In order to save both the current version and the restored backup, you must click “Restore” and select “Restore to”. Select the target folder for the recovered file.
  • To view archival copy: Click Open. The file has not been recovered, but you can view its contents to see if it contains the information you need.

4. Then click close Properties window when done. If previous versions no, you will see the message "There are no previous versions available after step 2. This means that the file is new and has not been copied, that the file has not changed, or that backup copy this file does not exist. The File History utility is not a replacement for recovering a file from the Recycle Bin; if you delete a file, you need to restore it from the Recycle Bin.

File History only works with files in the folders you selected when setting up the utility.

Video: How to recover an unsaved or damaged Microsoft Word, Excel or PowerPoint document

The following misfortune happened to me: I had a correct working file and I accidentally overwrote an empty one over the correct one. The information seemed to be lost, but a search on the Internet led me to one interesting advice. As I understand it, when deleting the file, the recipe will be the same.

My situation was not entirely standard, since the external processing of 1C 7.7 (file with *.ert extension) was overwritten.

So, having acquired the necessary software (WinHex.exe), I do the following:

  • Open WinHex.exe
  • Run command Tools → Open Disk
  • In the window that appears, select required disk and press OK

// If you need to recover a file from a flash drive, it’s better to select it in the list

Physical Media and not Logical Drive Letters (see Fig. 2)

Rice. 1. Selecting a recovery disk

// After opening the disk, its contents will be displayed in the program window in the form of hexadecimal codes

Rice. 2. Open drive in hexadecimal codes

If you have several partitions (Partition) and you know the partition on which the file was located before overwriting, then in the window you need to go to the corresponding partition. This will speed up recovery time.

  • Run command Tools → Disk Tools → File Recovery By Type
  • If a window appears as in Fig. 3 - press OK

Rice. 3. Warning that it is better to save recovered files on a different drive than the original ones

  • In my case, the situation was not entirely standard, since there was no file in the list of signatures external processing*.ert, so we do the following:
  • Click the “Signatures” button and add a new line:

ERT ert \xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1 0

ERT ert\xD0\xCF\x11\xE0\xA1\xB1\x1A\xE1 0

  • the signature is the first 8 bytes of the file in the required format, for *.ert it is taken for example like this, open any normal file and we see:

  • and now comparisons top line the first 8 bytes are with what I wrote earlier :)
  • after adding, select our new one in the list of signatures

Rice. 5. Selecting the format of the recovered files

  • In the same window, select the folder for the recovered files in the field Output folder(it’s better to choose a folder on a different drive than the drive on which the files are lost)
  • Click Ok
  • View the folder specified as Output folder using Windows Explorer- there should be recovered files there

Note:
The program dumps EVERYTHING into the user-specified folder erased files which can be restored. Recovered files, as a rule, are not displayed under their original names, i.e. If original file was called report.ert, then the recovered file can be called, for example, 00001.ert. If it is possible to restore several versions of one file, the program will do so, i.e. instead of one erased file report.ert, the program will throw it into Output folder files 00001.ert, 00002.ert, 00003.ert, etc. The user must select the “same” desired overwritten file independently. Also, along with the files in the Output folder will be created text file with a description of all recovered files, partially recovered (broken) files will be listed separately. Broken files have the letter “X” in their names, for example 00001X.ert.

After recovery, you can search or from the configurator or, for example, using the total commander to find the required file, the main thing is to know any text inside the file, the name of the variables, the name of the form elements...

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 the 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 file system- 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 |