Ezra Shiram
asked on
Script to Restore Files Based File Name
Hello,
We accidentally deleted files. We have a backup but it is not reliable and did not backup these files properly. A lot of them are missing. We do happened to have these missing files archived in another location. I would like to see if we can automate a restore from this archived location.
The main production network share has a structure of "C:\FTP Folder\PO#\Date\PO#_Item#\ League_Ite m#_Team_Pl ayer_Color \". To find this path in the "archived" location we need to use the last folder in the main production path (ex: League_Item#_Team_Player_C olor). So, after each underscore is another folder in the archived location. So we would go to the archived location and it would be "F:\League\Item#\Team\Play er\Color". Is there a script that we can make to pull the files from the archived location to the main production share?
Not sure if this is possible via a script, but that is what I am hoping for.
Thank You!!
We accidentally deleted files. We have a backup but it is not reliable and did not backup these files properly. A lot of them are missing. We do happened to have these missing files archived in another location. I would like to see if we can automate a restore from this archived location.
The main production network share has a structure of "C:\FTP Folder\PO#\Date\PO#_Item#\
Not sure if this is possible via a script, but that is what I am hoping for.
Thank You!!
Try this batch file:
echo off
set str="Folder\PO#\Date\PO#_Item#\League_Item#_Team_Player_Color\"
set str2=%str:Folder\PO#\Date\PO#_=F:\%
set str3=%str2:_=\%
echo %str3%
pause
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So, you want to look at each of these folders in the main server location, and then do what? Copy all files from the backup location? What if they already exist in the main server, overwrite, or skip?
~bp
~bp
REVISED:
If you need to process multiple folders in source folder c:\ftp, try this.
Note:
- I've placed an ECHO so you can see what the command does. It does not do the actual copy. To run it for real, remove the ECHO
- I used XCOPY command. Of course, use whatever command you like.
If you need to process multiple folders in source folder c:\ftp, try this.
Note:
- I've placed an ECHO so you can see what the command does. It does not do the actual copy. To run it for real, remove the ECHO
- I used XCOPY command. Of course, use whatever command you like.
echo off
setlocal enabledelayedexpansion
set arch=C:\FTP Folder\PO#\Date\PO#_Item#
set patt=*
set targetdir=c:\targetdir\
pushd %arch%
for /d %%a in (%patt%) do (
set str=%%a
set str2=!str:_=\!
ECHO xcopy /y /i /e "f:\!str2!" "%targetdir%"
)
popd
goto :eof
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
For a one-time restore, XCopy or RoboCopy may suit your needs.
Krompton