The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to monitor tmp folder for uploads mrfr0g Shell Programming and Scripting 6 08-19-2008 12:37 PM
need shell script for moving file one by one manojkarthi Shell Programming and Scripting 8 08-07-2008 04:54 AM
Moving Files from one folder to another folder farooqpervaiz Shell Programming and Scripting 10 08-07-2008 03:20 AM
Shell script to find out 2 last modified files in a folder..PLZ HELP!!!!!!!!! anju Shell Programming and Scripting 3 02-01-2008 01:47 AM
moving a file to a new folder and automated ftp dineshr85 Shell Programming and Scripting 1 10-05-2007 11:24 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-15-2008
viv1 viv1 is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 21
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
  #2 (permalink)  
Old 10-15-2008
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,372


Code:
dir_x=/path/to/directory_x
dir_y=/path/to/directory_y
datestamp=$(date +%Y%m%d)
cd "$dir_x" || exit 1
for file in *
do
 mv "$file" "$dir_y/${file}_$datestamp"
done

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0