LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Add Letter To Beginning of Files (https://www.linuxquestions.org/questions/linux-newbie-8/add-letter-to-beginning-of-files-4175499296/)

ryan.mongeau 03-24-2014 12:54 PM

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.

acid_kewpie 03-24-2014 12:59 PM

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.

ryan.mongeau 03-24-2014 01:13 PM

That worked! Thank you very much.


All times are GMT -5. The time now is 01:47 AM.