Move multiple files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Move multiple files
# 1  
Old 01-06-2011
Move multiple files

Hi all ..

I am trying :-
Code:
#! /bin/sh
# Archives target file ftp'd to SAP ECC
srcfiles=/usr/dw/apps/work/PROJECT_NEW/SrcFiles/$1/*.txt
tgtfiles=`ls /usr/dw/apps/work/PROJECT_NEW/TgtFiles/FTP/$1/*.txt`

for i in $tgtfiles
do

mv $i  /usr/dw/apps/work/PROJECT_HUDSON/archive/Tgt/$1/$i_`date +%Y%m%d_%H%M%S`.bkp
done

if [ -e $srcfiles ]; then
exit 15
else exit 0
fi

I get the following when I echo the mv command ..
/usr/dw/apps/work/PROJECT_NEW/archive/Tgt/IE0272/20110106_185552.bkp

It does not pick up the filename to append to the timestamp ..

Any ideas?

Last edited by Franklin52; 01-06-2011 at 02:11 PM.. Reason: Please use code tags
# 2  
Old 01-06-2011
did you try
Code:
...
for i in /usr/dw/apps/work/PROJECT_NEW/TgtFiles/FTP/$1/*.txt
...

or
Code:
 
...
tgtfiles="/usr/dw/apps/work/PROJECT_NEW/TgtFiles/FTP/$1/\*.txt"
for i in $tgtfiles
...

# 3  
Old 01-06-2011
Yes same issue .. filename $i missing ..
# 4  
Old 01-06-2011
Code:
ls /usr/dw/apps/work/PROJECT_NEW/TgtFiles/FTP/$1/*.txt |where read i
do
  mv $i  /usr/dw/apps/work/PROJECT_HUDSON/archive/Tgt/$1/$i_`date +%Y%m%d_%H%M%S`.bkp
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Rename (move) multiple files on remote server using sftp

I want to rename (move) multiple files on remote server. I tried the following command to move all TXT files from my_dir directory to /new_dir. But it does not work. Any help? #!/bin/ksh sftp -dev3 << ABC cd my_dir $(for i in TXT; do echo "ls *.$i" ; rename $x /new_dir/$x;... (1 Reply)
Discussion started by: Soham
1 Replies

2. Shell Programming and Scripting

Move multiple files to different directory using a single command

I have multiple files test1, test2, test3 etc. I want to move to a different directory with ABC_ prefixed to every file and and current dat time as postfix using a single command. (I will be using this is sftp with ! (command for local server). I have tried the following but it gives error ... (5 Replies)
Discussion started by: Soham
5 Replies

3. Shell Programming and Scripting

Move multiple files 4rm Source to different target folders based on a series num in the file content

Dear Experts my scenario is as follows... I have one source folder "Source" and 2 target folders "Target_123456" & "Target_789101". I have 2 series of files. 123456 series and 789101 series. Each series has got 3 types of fiels "Debit", "Refund", "Claims". All files are getting... (17 Replies)
Discussion started by: phani333
17 Replies

4. Shell Programming and Scripting

SBATCH trinity for multiple files and rename/move the output files

Hey guys, I have wrote the following script to apply a module named "trinity" on my files. (it takes two input files and spit a trinity.fasta as output) #!/bin/bash -l #SBATCH -p node #SBATCH -A <projectID> #SBATCH -n 16 #SBATCH -t 7-00:00:00 #SBATCH --mem=128GB #SBATCH --mail-type=ALL... (1 Reply)
Discussion started by: @man
1 Replies

5. Shell Programming and Scripting

Sort and move multiple files by modification date

Hi I have a problem, I have a large group of archive files in a folder some are later versions of the same archive, the only difference btween them is that the archiving program we use appends the name with a code for it to keep track of in its data base, and the modification date. I am starting... (6 Replies)
Discussion started by: Paul Walker
6 Replies

6. UNIX for Dummies Questions & Answers

Move Multiple Files adding date timestamp before file type

There are files in a directory and I have to move multiple files adding datetimestamp before the file type. /Data/ abc.csv def.csv ghi.csv I have to move this files to archive directory adding datatimestamp before .csv /archive/ abc_YYYYMMDDHHMMSS.csv def_YYYYMMDDHHMMSS.csv... (7 Replies)
Discussion started by: eskay
7 Replies

7. Shell Programming and Scripting

Script to move files in multiple folders

Hello all, I would appreciate any help to write a script. I have folder A which contains over 30 thousands xml files, I would like create multiple folders and move those files (500 in each folders). Thank you (1 Reply)
Discussion started by: mmsiddig
1 Replies

8. Shell Programming and Scripting

To move multiple files to a new folder everytime

Hi , Below is the scenario A.txt B.txt C.csv .......... i want to move all the above files in to a new path & new folder .This folder is created based on date(for ex: today's fodler name will be 20120222).for Everyday move a new folder based on date has to be created & this folder... (1 Reply)
Discussion started by: jagadeeshn04
1 Replies

9. UNIX for Dummies Questions & Answers

Multiple stage file move?

Greetings all. I need is a script that will move a file from one known dir to another, then grab another file from a different dir to replace it, and have absolutely zero clue how to do this. Here's what I am trying to do: A web client wants his site header image to change based on US... (2 Replies)
Discussion started by: ccvortex
2 Replies

10. Shell Programming and Scripting

Find, Append, Move & Rename Multiple Files

Using a bash script, I need to find all files in a folder "except" the newest file. Then I need to insert the contents of one text file into all the files found. This text needs to be placed at the beginning of each file and needs a blank line between it and the current contents of the file. Then I... (5 Replies)
Discussion started by: Trapper
5 Replies
Login or Register to Ask a Question