Current location: Hot Scripts Forums » Programming Languages » Perl » script that updates a file but in many directories


script that updates a file but in many directories

Reply
  #1 (permalink)  
Old 04-27-04, 01:56 PM
nick1 nick1 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
script that updates a file but in many directories

Greetings,
i have a .txt file called 'Master' and 75 user directories each containing the same 'Master' .txt file.

When i make changes to this 'Master' file i then have to copy & paste it into each of these 75 user directories.

So, my question is:

is there a script that can do all of this for me? A script that looks for changes in the 'Master' file and, if it detects changes, updates the 'Master' file in the 75 user directories.

Thank you for your time,

Nick
Reply With Quote
  #2 (permalink)  
Old 04-27-04, 03:49 PM
feha feha is offline
Wannabe Coder
 
Join Date: Mar 2004
Posts: 141
Thanks: 0
Thanked 0 Times in 0 Posts
I suggest

Hi
I suggest You that master.txt file you move to one level up of your user dirs ...
And change the path on your application to find master.txt in that new location ...
(I supose the content of master.txt is the same ...)
regards
__________________
www.flashwebshop.org/
Reply With Quote
  #3 (permalink)  
Old 04-30-04, 09:16 AM
nick1 nick1 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
umm....

huh?
Reply With Quote
  #4 (permalink)  
Old 05-02-04, 05:13 AM
Skeleton Man Skeleton Man is offline
Community Liaison
 
Join Date: Jun 2003
Location: Australia
Posts: 406
Thanks: 0
Thanked 0 Times in 0 Posts
May I ask what the purpose of this file is ? There may be a better alternative to 75 copies of the same file.. If you really have to do this, use the File::Find module; this will get you a recursive listing of a given directory, from which you can work on your own code to copy a file or whatever...
Reply With Quote
  #5 (permalink)  
Old 05-03-04, 09:23 AM
nick1 nick1 is offline
Newbie Coder
 
Join Date: Apr 2004
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you for replying,

Roster.txt is a roster file that contains 75 user names. This file is used with the Merak Instant Messaging server and with Miranda Instant messanger, both which use the jabber protocol to communicate.

Each user has a folder which is called their username (whatever it may be). Inside that folder is a folder called ~IM then inside that folder is the roster.txt file. I too have a copy of the roster.txt file. I make changes to this file when need be then copy it into the user folders so that their roster.txt file is also updated.

I don't know much about coding however. I've tried using junction points in windows (which are similiar to symbolic links as used in unix) however junction points only create a link to a directory - i need FILE link junctions - because there are other files within the users folder other then roster.txt.

Can someone please help me out.

Thank you for your time,

Nick

my O.S. is winXP pro


Quote:
Originally Posted by Skeleton Man
May I ask what the purpose of this file is ? There may be a better alternative to 75 copies of the same file.. If you really have to do this, use the File::Find module; this will get you a recursive listing of a given directory, from which you can work on your own code to copy a file or whatever...
Reply With Quote
  #6 (permalink)  
Old 02-13-05, 02:04 AM
loftinlouie loftinlouie is offline
New Member
 
Join Date: Feb 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Using the 'for' command to solve your problem.

You could create a batch file with the following:

@echo off
cls
echo.
echo.
echo Deleting any existing colorado_users.txt & cp_dict_log.txt files.

if exist "colorado_users.txt" del "colorado_users.txt"
if exist "cp_dict_log.txt" del "cp_dict_log.txt"

echo.
echo.
echo Piping the dir /b command to a text file named colorado_users.txt.
echo.
echo Please note you need to change co* to something like *.* or whatever your naming convention for users begins with.

dir /b "c:\Documents and Settings\co*" > "colorado_users.txt"

echo.
echo.
echo Adding the read-only attribute to the specified file.

attrib +r "dict.vtc"

echo.
echo.
echo Then 'for' runs the xcopy /c/r/k/y/v "filename" "<path>" command and pipes it to a log file.
echo.
echo As you already know you could replace the > with >> to append to a log file instead.
echo.
echo It replaces %%a with the names it found in colorado_users.txt.

for /f %%a in (colorado_users.txt) do xcopy /c/r/k/y/v "dict.vtc" "c:\test\Documents and Settings\%%a\application data\ccwin\" > "cp_dict_log.txt"

echo.
echo.

pause


Reply With Quote
  #7 (permalink)  
Old 02-13-05, 03:27 AM
phprogramming phprogramming is offline
Wannabe Coder
 
Join Date: Nov 2004
Posts: 214
Thanks: 0
Thanked 0 Times in 0 Posts
php could do it SO easily
__________________
Source Code Talk - Programming Discussion, Tutorials, and More!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with my largest perl script. Grabbing data from a file. Sunnmann Perl 2 04-23-08 03:27 AM
Is there any integrity of script rankings? webmaster@atmanager.com Hot Scripts Forum Questions, Suggestions and Feedback 17 08-06-04 12:12 AM
script that updates one file but in many directories nick1 Script Requests 0 04-27-04 12:21 PM
How to write a php script to load a text file into a table automatically? xmxpcom PHP 2 02-12-04 08:37 AM
ZIP/RAR file comment/.diz/.nfo viewer script net4ward Script Requests 0 11-19-03 04:41 PM


All times are GMT -5. The time now is 04:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.