The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Changing old file name to new one if the old file name satisfied certain condition balzzz UNIX for Dummies Questions & Answers 1 02-17-2008 10:41 AM
sed and changing the file itself melanie_pfefer Shell Programming and Scripting 2 01-22-2008 11:19 PM
changing to a different file kev269 Shell Programming and Scripting 5 04-11-2006 11:07 AM
Changing Pattern in a file pbtenneti Shell Programming and Scripting 0 03-15-2006 06:58 AM
changing file permissions gagansharma Shell Programming and Scripting 0 11-27-2001 11:26 PM

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 01-28-2008
balzzz balzzz is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 8
Infractions: 0/0 (0)
Changing the File Name

Dear all,

I want to change all the File name in a folder from File1.txt to
File1YYYYMMDD.txt where YYYYMMDD is the date of the file is renamed.

I have used the following scripts:-

********************************************************
#!/bin/ksh

A=`date +"%d%m%Y"

for in [File]*
do
mv $i $i$A.txt
done

********************************************************

But when I used this script, all the file is instead changed into
File1.txtYYYYMMDD.txt

How do I remove the first .txt after the character File1? Please advised on this.

Thanks alot.
  #2 (permalink)  
Old 01-28-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj - the student
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 597
Infractions: 0/0 (0)
Try this:

Code:
mv $i ${i%%.txt}$(date +"%d%m%Y").txt
  #3 (permalink)  
Old 01-28-2008
balzzz balzzz is offline
Registered User
  
 

Join Date: Jan 2008
Posts: 8
Infractions: 0/0 (0)
Thanks alot. It works. But can you please explain why by putting (i%%.txt) it is working? Sorry for asking stupid questions. I am still new in this field.

Thanks again for helping me.
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 08:36 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