LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices



Reply
 
Search this Thread
Old 07-02-2008, 01:30 AM   #1
manojkarthi
LQ Newbie
 
Registered: Jun 2008
Location: now in new delhi
Posts: 1

Rep: Reputation: 0
Question how to mv the files...urgent...urgent




how to mv the files one by one to another folder...
using scripts...

while running the script....i want to take one file ...from
files directory...to processing dir...after processing,another file ..like that..

note: Script can process only one file at a time..
plz reply ASAP


below script i tried ...but it's not working

for file in $PATH1/*
do
file= (here i don't know)..in this line ..problem

mv $PATH1/$file $PATH2

/* call my script*/

done

Plz hlp mi

....Karthika
 
Old 07-02-2008, 01:48 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Is there anything wrong with the code below? The loop variable ($file) already contains the name of the file.

Code:
for file in $PATH1/*
do
  mv $file $PATH2
done
Also, please don't use "urgent" in your thread titles, as it isn't going to help you get help any faster and your thread is no more important than anyone else's.

Last edited by Nylex; 07-02-2008 at 02:00 AM.
 
Old 07-02-2008, 03:21 AM   #3
Woodypecker
Member
 
Registered: Mar 2006
Location: Austria
Distribution: Mandriva/Debian
Posts: 102

Rep: Reputation: 17
#!/bin/sh
if [ "$#" -lt '2' ]
then
echo $0: Usage: $0 SOURCEDIR TARGETDIR \[Extension]
exit 2
fi
SOURCEDIR="$1"
TARGETDIR="$2"
EXT="$3"
for i in `ls -F "$SOURCEDIR"/*"$EXT"|grep -v /$`
do
mv "$SOURCEDIR"/"$i" "$TARGETDIR"
if [ "$?" -eq '0' ]
then
echo "$i" successfully moved
# .... add your processing here ....
else
echo error moving "$i" - no processing for this file
# .... echo break command if you desire ...
fi
done
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
boot sector and lilo collapse !!!!! URGENT URGENT URGEN !!!!! frelihm Linux - Software 21 12-02-2009 11:21 AM
Urgent Question Regarding Urgent Questions! Need Help Now! Crashed_Again LQ Suggestions & Feedback 11 10-17-2007 09:07 PM
urgent! how to recover files from os x? stairwayoflight Other *NIX 12 06-10-2007 07:55 PM
Urgent - wanna know boot files for 2.6.3 kernel coolamit78 Linux - Software 5 02-22-2004 04:24 AM
Urgent Urgent !!!! Mozilla Keeps All Your Deleted Emails !!!! odin123 Linux - Software 2 01-31-2004 03:22 AM


All times are GMT -5. The time now is 07:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration