View previous topic :: View next topic |
Author |
Message |
Doctor Feelgood Arrrrghh!
Joined: 07 Apr 2003 Posts: 20349 Location: New Jersey
|
Posted: Wed, 08 Aug 2007 19:45:16 Post Subject: Batch copy and edit application? |
|
|
The website has old files that need to be updated and I am looking for a quick and easy way. I need to do two things.
1. There are numerous old folders that among their different contents all have the same file in them that needs to be replaced. Is there a quick way to copy one new file and have it dropped into dozens folders at once to replace what is already there?
2. There are also a variety of files in these folders that have the same name, and have the same basic content, but some variables. Is there a way to do a batch "replace all" inside these files to update select content?
|
|
Back to top |
|
|
Little Bruin
Boo Boo
Joined: 07 Apr 2003
Posts: 667
Location: Pic-A-Nic Basket |
|
|
knight0334 Rated XXX
Joined: 22 Aug 2003 Posts: 2234 Location: Neither Here, Nor There
|
Posted: Thu, 09 Aug 2007 13:11:14 Post Subject: |
|
|
XCOPY command is your friend.
http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/xcopy.mspx?mfr=true
You can do most, if not all of that with XCOPY. For each directory you would have to copy on individual command lines.
Our old cable tv database had several directories, with many files in each.. sometimes named the same, but the extention changed ( .001 or .002 or .099 etc). WinXP wouldn't recognize the RAID controller of a mobo we had for the server, so I used a batch file to XCOPY the data across (2) HDDs with (4) partitions each. One partition was the actual daily used database, one was daily backup, another was a bi-weekly, another was a monthly. It'd make it's timed backup at 3-4am, then mirror to the other drive as soon as the backup was made. |
|
Back to top |
|
|
BeerCheeze *hick*
Joined: 14 Jun 2003 Posts: 9285 Location: At the Bar
|
|
Back to top |
|
|
knight0334 Rated XXX
Joined: 22 Aug 2003 Posts: 2234 Location: Neither Here, Nor There
|
|
Back to top |
|
|
Blue|Fusion Rated XXX
Joined: 30 May 2005 Posts: 441 Location: Cleveland, OH
|
Posted: Thu, 09 Aug 2007 14:39:56 Post Subject: |
|
|
1. You can make a script to use rsync on all of the directories. Something like this:
Code: |
dir_list="/home/dir1
/home/dir2
/home/dir3"
for dir in $dir_list; do
rsync -av /root/new.file $dir
done |
2. sed. After you finally get a working sed command that does what you want, it might have been faster doing it all by hand depending how many files there are. _________________ 5 home-built PCs, ASUS A6Jc Laptop, and a PowerEdge 2650 - all running Gentoo. Now if only I can get a car and plane to run it. Take a look at my Gallery! |
|
Back to top |
|
|
Doctor Feelgood Arrrrghh!
Joined: 07 Apr 2003 Posts: 20349 Location: New Jersey
|
|
Back to top |
|
|
|