Computing.Net > Forums > Windows XP > copy and replace via batch file

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

copy and replace via batch file

Reply to Message Icon

Name: jerblaster23
Date: January 15, 2006 at 13:27:52 Pacific
OS: XP Pro
CPU/Ram: 512 mb
Comment:

hi I am simply trying to copy one file to replace and overwride it via a batch file, esentally trying to wipe clean my database csv file with a blank newley formated file, I can do this via a shortcut to a zip file to reset it but I want a single click solution.

source:
D:\My Documents\My Data Sources\reset\data.csv

destination:
D:\My Documents\My Data Sources\data.csv

sorry I realyze this is a really simple task, but I no almost nothing about batch files so if you can tell me what code I need for this I would really appeiciate it, the original file of course would need to remain so I can run this again and again. thanks




Sponsored Link
Ads by Google

Response Number 1
Name: Jennifer SUMN
Date: January 15, 2006 at 15:56:35 Pacific
Reply:

Your post is confusing. You say "copy one file to replace and overwride it via a batch file, esentally trying to wipe clean my database csv file with a blank newley formated file". Then you say "the original file of course would need to remain."

So which is it? Do you want to replace the file or keep the original?

Soylent Green is PEOPLE!!!


0

Response Number 2
Name: Impavidus
Date: January 15, 2006 at 16:23:58 Pacific
Reply:

Here you go mate: The first script will replace the original file with the blank one, WITHOUT asking you to confirm overwrite, and WITHOUT backing up the old file.

The second script will ask you to press any key before continuing, and will back up the original file before replacing it with the blank. The backup copy will be named data.csv_old.

1st Script:
--------------
@echo off
cls
D:
cd\my documents\my data sources
copy data.csv data.csv_old
copy .\reset\data.csv data.csv /Y

2nd Script:
--------------
@echo off
cls
echo This will replace D:\My Documents\My Data Sources\data.csv with D:\My Documents\My Data Sources\reset\data.csv.
echo Press any key to continue, or press CTRL+C to terminate the batch job.
pause > nul
D:
cd\my documents\my data sources
copy data.csv data.csv_old
copy .\reset\data.csv data.csv /Y
echo The procedure is complete. Please check data file.
pause > nul


Copy and paste either script into notepad, and save as a batch file (.bat) by enclosing the filename in quotes, e.g. "replace.bat".

Reply if this helped :)

Impavidus



0

Response Number 3
Name: jerblaster23
Date: January 15, 2006 at 23:34:16 Pacific
Reply:

sorry for the confusion in my post, and thanks Impavidus works great and did just what I need, you guys are awsome.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


Media Player headaches Long hangup after selecti...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Windows XP Forum Home


Sponsored links

Ads by Google


Results for: copy and replace via batch file

Find and Replace using Batch File www.computing.net/answers/windows-xp/find-and-replace-using-batch-file/178634.html

difference b/w %%g and %g% in batch file www.computing.net/answers/windows-xp/difference-bw-g-and-g-in-batch-file/176113.html

Batch file to install msi and check errorlvl www.computing.net/answers/windows-xp/batch-file-to-install-msi-and-check-errorlvl/178657.html