LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-24-2014, 01:54 PM   #1
ryan.mongeau
LQ Newbie
 
Registered: Aug 2013
Location: Sterling, MA
Distribution: Debian 6.0
Posts: 9

Rep: Reputation: Disabled
Add Letter To Beginning of Files


Hello,

I'm having a bit of trouble figuring out how to do this. I have a bunch of PDFs that have 6 number file names. I want to add W- to the beginning of each one. So, 123456.pdf would change to W-123456.pdf

How the heck should I go about this?

Thanks.
 
Old 03-24-2014, 01:59 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
something like this?

Code:
thinkpad log # ls -1
2013-05-04.165015.log
2013-05-05.034835.log
2013-05-08.062340.log
2013-05-31.161615.log
2013-06-19.173652.log
2013-07-22.174504.log
2013-10-10.212507.log
2013-11-23.135733.log
2013-12-17.185114.log
2013-12-20.225309.log
2014-01-22.215823.log
2014-02-21.194024.log
thinkpad log # ls -1 | xargs -I x echo mv x W-x
mv 2013-05-04.165015.log W-2013-05-04.165015.log
mv 2013-05-05.034835.log W-2013-05-05.034835.log
mv 2013-05-08.062340.log W-2013-05-08.062340.log
mv 2013-05-31.161615.log W-2013-05-31.161615.log
mv 2013-06-19.173652.log W-2013-06-19.173652.log
mv 2013-07-22.174504.log W-2013-07-22.174504.log
mv 2013-10-10.212507.log W-2013-10-10.212507.log
mv 2013-11-23.135733.log W-2013-11-23.135733.log
mv 2013-12-17.185114.log W-2013-12-17.185114.log
mv 2013-12-20.225309.log W-2013-12-20.225309.log
mv 2014-01-22.215823.log W-2014-01-22.215823.log
mv 2014-02-21.194024.log W-2014-02-21.194024.log
And then just remove the "echo" to actually do it.
 
Old 03-24-2014, 02:13 PM   #3
ryan.mongeau
LQ Newbie
 
Registered: Aug 2013
Location: Sterling, MA
Distribution: Debian 6.0
Posts: 9

Original Poster
Rep: Reputation: Disabled
That worked! Thank you very much.
 
  


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
How could i add to the beginning of line word? DoME69 Programming 6 09-17-2008 03:55 AM
Delete specific lines of a file beginning with a certain letter docaia Programming 4 08-25-2008 12:04 AM
need a list of every installed RPM beginning with the letter "j" me210 Linux - Software 2 01-17-2007 11:59 AM
Add Text to Beginning of 200 Files dougp23 Linux - Newbie 3 10-30-2006 04:01 PM
How to add data at file beginning in C? Nad0xFF Programming 8 04-17-2005 12:48 PM


All times are GMT -5. The time now is 08:56 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration