?
Solved

How to create a windows batch file to archive users files in XP?

Posted on 2010-11-10
9
Medium Priority
?
519 Views
Last Modified: 2013-12-24
Hi,

Can you tell me how to write a windows batch file script to archive a user or users files in XP?


Many thanks
Sandy.
0
Comment
Question by:sweetiepie70
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 

Accepted Solution

by:
jasonabarnett earned 500 total points
ID: 34106367
Hi Sandy,

Let's assume the users files are stored in a location called C:\Files.

Let's also assume you want to archive them to a network drive called F:\Archive.

Let's assume you want a unique Archive folder for each user too.

I'd do something like the attached.

Regards,

Jason
REM check if F: is mapped and if so disconnect it
if exist F:\ net use F: /d

REM map F: to \\myserver\myshare
net use F: \\myserver\myshare

REM check if archive folder exists and if not then create it
if not exist F:\Archive\%username% mkdir F:\Archive\%username%

REM copy user data to archive folder
xcopy /E /R /Y /C C:\File F:\Archive\%username%

REM disconnect network drive
net use F: /d

Open in new window

0
 

Author Comment

by:sweetiepie70
ID: 34106672
Jason,

Many thanks for this.  I was wondering if there was a simpler way to achieve this.


Sandy
0
 
LVL 57

Expert Comment

by:Bill Prew
ID: 34107158
Can you be any more specific about what you are looking for?  Is this something you will run on the actual computer where the user files exist, or remotely?  What types of files or information are you looking to save?  And where do you want to save it, to the same PC, or to a network location, etc?

~bp
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:sweetiepie70
ID: 34107269
Hi BP,

I would like to save it on say an external drive or usb drive from the c drive on a computer or laptop.  The files will be on that computer or laptop but will be archived to an external drive/usb drive.


Regards
Sandy
0
 
LVL 7

Assisted Solution

by:justadad
justadad earned 500 total points
ID: 34109294
The above batch file could be shortened quite a bit, however he put in some nice checks on if something exists. The biggest problem about doing it to an external drive will also be in the launching of the batch file to know what the destination drive letter is.

One way to do this would be to place the batch file on the removable media and run it from there, but you have to do some fancy foot work to get the path.
So it would be something like this:

Replace F:\ with %~dp0

That will get around determining where to copy the files to.

One last thing and that is the xcopy will always copy all of the files. You could add a /d which would only copy newer files. But again that will not delete any files that have been removed. This is not truly an archive as any new file will overwrite the old.  To get around these limitations you would need to install a tool such as robocopy or 7zip and call them from the cmd file.
REM copy user data to archive folder
xcopy /E /R /Y /C /D C:\File %~dp0Archive\%username%

Open in new window

0
 
LVL 38

Expert Comment

by:BillDL
ID: 34183142
Just for your info, and is not intended to divert from the excellent advice and suggestions above.  You may be interested in a little free program named "Shadow Copy" http://www.runtime.org/shadow-copy.htm).
It provides a simple user interface to copy directories, and overcomes the problem of files currently in use not being copied. It does this by using the Windows Volume Shadow Copy Service. It can be run from the command line also.
0
 
LVL 8

Expert Comment

by:Here2Help
ID: 34362583
Hey.

Try 'Sync'.
http://syncdir.sourceforge.net/

Copy Sync.jar and Sync.bat (from the windows folder in the zip file) to a folder and call it Sync.  Sync.bat will need to be edited so open it up in to notepad.

If you supply specific information such as the exact folder path you want to archive.  Whether overwriting matching files shud be allowed or just rename matching names on-the-fly.  Also any file types that shouldn't be included for archive then me and the experts can put it together for you.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 34626701
This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question