File Moving Script


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers File Moving Script
# 1  
Old 04-20-2011
File Moving Script

I want to make a script that moves all files with a keyword on it to another folder. and lets me know how many files it moved with that keyword. Im a total newbie with scripting so a little help would be much appreciated.
# 2  
Old 04-20-2011
Code:
#/bin/ksh  -x
file_name=`ls *key_word*`
for i in ${file_name}
do
cp ${i} /home/target_dircetory
count=`expr ${count} + 1 `
done
echo "number of file transferd = ${count} "

Replace key_word with the word you want to search and replace /home/target_dircetory with your direcoty adress
# 3  
Old 04-20-2011
Code:
num=0
for files in *keyword*
do
  cp $files /destination && ((num++))
done
echo "how many files : $num"

# 4  
Old 04-20-2011
find / -name "*keyword*" -print -exec mv {} /target/dir \;
This User Gave Thanks to brij123 For This Post:
 
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Beginner need help how file moving script could look like

Hi there, I am an absolut beginner in scripting. I am using Ubuntu Linux 18.04 LTS: I just need some hints/suggestions how a script could look like doing the following stuff: assuming I am in directory "base_directory" like xyz@mypc:~/base_directory$ within the "base_directory there... (1 Reply)
Discussion started by: dut42
1 Replies

2. Shell Programming and Scripting

Script for moving one file with date content in name

Dear All, I am having a database that generates daily backup files in the below format. abc_date_0010.zip. Can you please suggest a method to copy the last day's file to another location. I am trying with if statement, but having difficulty while I use the condition like if ; then ... (4 Replies)
Discussion started by: skooby
4 Replies

3. UNIX for Dummies Questions & Answers

Running a script from another script by moving directories

I have created this script and does not seem to be behaving well. Basically I am in a directory, I just want to do down two directories, run the script georom_replaceText.tcsh This will produce a file in the subdirectory, which I then run. Finally go back to where I started. Afterwards I... (4 Replies)
Discussion started by: kristinu
4 Replies

4. Shell Programming and Scripting

Shell Script for moving 3 days old file to Archive Folder

Hi Experts, I have a "Source" folder which may contain some files. I need a shell script which should move all files which are older than 3 days to "Archive" folder. Thanks in Advance... (4 Replies)
Discussion started by: phani333
4 Replies

5. Ubuntu

Moving folders with script

Hi All, I am new to Forums, as i am struggling for one script i am launched here. I need to move more than 60,000+ folders in 1,00,000 folders to another server. I have the list of folders which should be moved. can anybody help me in sharing with the script for the above requirement. ... (4 Replies)
Discussion started by: ghimakiran
4 Replies

6. Shell Programming and Scripting

moving file to directory in script

hi i am reading files from directory,if the files matches certain condition i need to move that file to another directory i am using if then mv $file1 > $UNIQDIR fi but i am gettin error , please help thanks Satya (4 Replies)
Discussion started by: Satyak
4 Replies

7. Shell Programming and Scripting

shell script for moving all the file from the same folder

Hi , I need a shell script which basicaly moves all the files from one folder say folder x to folder y and once they are moved to folder y a datetimestamp should be attached to there name for ex file a should be moved to y folder and renamed as a_20081015 (1 Reply)
Discussion started by: viv1
1 Replies

8. Shell Programming and Scripting

need shell script for moving file one by one

#SD=source dir TD= target dir SD="$/amddev/app01/manoj/new/scripts/old" TD="$/amddev/app01/manoj/new/scripts/new" EXT="$*.txt" for i in `ls -F "$SD"/*"$EXT"|grep -v /$` do mv "$SD" "$TD" if then echo "$i" successfully moved echo Manoj successfully..1 ( here i... (8 Replies)
Discussion started by: manojkarthi
8 Replies
Login or Register to Ask a Question