copy and rename file..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting copy and rename file..
# 1  
Old 12-08-2010
copy and rename file..

hi all,

I have one config folder and updates folder.updates folder contains file tmp_2.0_20201208_45.xml and config folder contains file tmp.xml.When the tmp_2.0_20201208_45.xml file is copied in the config folder the name of this file is changed in config folder again as tmp.xml(old filename)(After copied this tmp_2.0_20201208_45.xml in config folder name is changed again as tmp.xml file.) plz help me how to write shell script ...

Last edited by shubhig15; 12-08-2010 at 07:44 AM..
# 2  
Old 12-08-2010
install 'File::Copy::Recursive' module and mentioned your your input_dir and output directory at the corresponding place.
Code:
perl -e 'use File::Copy::Recursive qw(dircopy); dircopy('/home/input_dir', '/home/output_dir');

# 3  
Old 12-08-2010
Quote:
Originally Posted by k_manimuthu
install 'File::Copy::Recursive' module and mentioned your your input_dir and output directory at the corresponding place.
Code:
perl -e 'use File::Copy::Recursive qw(dircopy); dircopy('/home/input_dir', '/home/output_dir');

thanks..i dose not want code in perl..i want shell script in c
# 4  
Old 12-08-2010
from inside your updates directory:-

cp -f tmp_2.0_20201208_45.xml ../config
# 5  
Old 12-08-2010
use cp command with full OR relative file paths like:
cp tmp_2.0_20201208_45.xml <path>/

Last edited by anurag.singh; 12-08-2010 at 07:48 AM..
# 6  
Old 12-08-2010
Quote:
Originally Posted by robfwauk
from inside your updates directory:-

cp -f tmp_2.0_20201208_45.xml ../config
(After copied this tmp_2.0_20201208_45.xml in config folder name is changed again as tmp.xml file.)
# 7  
Old 12-08-2010
As anurag.singh suggests also try full paths

e.g.

cp -f <full_path>/updates/tmp_2.0_20201208_45.xml <full_path>/config/tmp_2.0_20201208_45.xml
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash to copy file 3 times and rename based on another file

In the below bash I am trying to copy the only text file (always only one) in /home/cmccabe/Desktop/list/QC/metrics.txt and rename each of the 3 text files according to /home/cmccabe/Desktop/test/list.txt using lines 3, 4 ,5. This format (that is list.txt) is always 5 lines. Thank you :). ... (12 Replies)
Discussion started by: cmccabe
12 Replies

2. Shell Programming and Scripting

Need help in writitng a script to rename file name and copy to other folder

Hi All, My requirement is as follows: A file (say abc) will be having list of the .txt file names. I need to read this abc file line by line and rename the .txt file names inside it and move them to other folder/path. Eg: abc ------- file1.txt file2.txt file3.txt Output (should... (1 Reply)
Discussion started by: pavan.yadalla
1 Replies

3. Shell Programming and Scripting

[Solved] copy + rename

Hi, I was thinking that this should be a synch but I could never get it to work. I want to copy a bunch of files within a directory (3/4 levels into the directory) to a common place. All these files have the same name, so I prefer to rename them with the path. I tried with files=`ls -1... (5 Replies)
Discussion started by: jamie_123
5 Replies

4. Shell Programming and Scripting

.sh file To rename existing file and copy new file

Hi All, I am very new to shell scripting . In my current task i want to create .sh file that will rename the existing file with appending _bu in it. And then copy new file . e.g if i have file linuxFirst.java then i want to rename it to linuxFirst_bu.java ..Then want replace with latest... (1 Reply)
Discussion started by: maheshkaranjkar
1 Replies

5. Shell Programming and Scripting

Files rename and copy

hello, I am write a Script and i would listing all Files from Path1 out with DSR*.txt and give a new name an copy to the Path2. I have problems with that to rename. Someone can help me? Sorry, for my english. My english is not gut. I hope you understand my. That is my Script. ... (2 Replies)
Discussion started by: efeijoo
2 Replies

6. Shell Programming and Scripting

Copy files from folder and rename them

hello, I need to build a shell script that receives the folder to copy by parameter and copy all files except thumb.db to another folder and rename them like, file.jpg renamed to file_bb1.jpg. can someone help me Thanks (4 Replies)
Discussion started by: zeker
4 Replies

7. Shell Programming and Scripting

Copy 1 file 5000 times and Rename each +1

Hi, Found lots of stuff that is close but no cigar... I have a file ie. a.txt, and I want to copy it to another directory 5000 times and call it: a1.txt a2.txt ... a5000.txt Struggling to put a loop together in this new world of AIX. please include full script for me to understand... (3 Replies)
Discussion started by: terry2009
3 Replies

8. Shell Programming and Scripting

copy/rename file as date() unix/shell

File.jpg I want to copy and rename this as 2008-12-02.jpg I tried this copy File.jpg date '%y-%m-%d-%H:%M:%S'.jpg This doesnt work.... what do i do? (1 Reply)
Discussion started by: hdogg
1 Replies

9. UNIX for Dummies Questions & Answers

Mass Copy/rename

Don't tell me DOS can do something UNIX can't do! I want to copy a number of files from one directory to another, and at the same time change the names. The name changes would be common, e.g., all files starting with the letter 'L' and ending in '30.NEW554', with the copied or new files also... (6 Replies)
Discussion started by: lwilsonFG
6 Replies

10. UNIX for Dummies Questions & Answers

copy and rename list of files

Hi all, I am a newbie in writng unix..I am using ksh shell..Does anyone know how to copy a list o files from directory A to directory B with differnt names? i.e in Dir A, I have RPT101.555.TXT RPT102.666.TXT and I want to copy those files to dir B with new naming convention.. in Dir B,... (7 Replies)
Discussion started by: kinmak
7 Replies
Login or Register to Ask a Question