Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Using Fedora
FedoraForum Search

Forgot Password? Join Us!

Using Fedora General support for current versions. Ask questions about Fedora and it's software that do not belong in any other forum.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 24th March 2008, 11:56 AM
Nico M Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
How replace strings in filenames with scripts?

Hey,

I have a question about scripting, for which I didn't see a seperate forum.

I have a group of xml-files linked to each other and with strings like "yymmdd" in their names. Manually I replace the string by a date (like "080324") when I want to update a file.

Now I wondered if there was a script for that. I already wrote a small script which replaces these strings inside the files, but is it also possible to replace the string in the filenames? If not, I should think of another system...
Reply With Quote
  #2  
Old 24th March 2008, 02:25 PM
daneel971's Avatar
daneel971 Offline
Registered User
 
Join Date: Jun 2005
Location: Italy
Posts: 1,108
Code:
for i in *.xml; do mv -v $i ${i/yymmdd/`date +%y%m%d`}; done


use "cp" for testing, instead of "mv".
__________________
- Captain...
- Yes, Spock?
- I can't believe my ears...
Reply With Quote
  #3  
Old 24th March 2008, 07:45 PM
Nico M Offline
Registered User
 
Join Date: Feb 2006
Posts: 7
Quote:
Originally Posted by daneel971
Code:
for i in *.xml; do mv -v $i ${i/yymmdd/`date +%y%m%d`}; done


use "cp" for testing, instead of "mv".
Hai Daneel971,

it works perfect!
thanks a lot!

Nico
Reply With Quote
Reply

Tags
filenames, replace, scripts, strings

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
inputting Strings in C?? A_n_H Programming & Packaging 5 5th April 2009 09:52 PM
sockets and strings fizy Programming & Packaging 4 10th May 2008 10:40 PM
Returning strings in C pepribal Programming & Packaging 6 25th February 2007 03:14 PM
a little java help with Strings sublime Programming & Packaging 7 15th April 2006 10:15 PM


Current GMT-time: 03:37 (Monday, 20-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat