Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
09-11-2002, 02:01 AM
|
#1
|
Member
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747
Rep:
|
can i do this in shell?
a.txt a2.txt bdf.txt akfler.txt
=>
a.pdf a2.pdf bdf.pdf akfler.pdf
??
|
|
|
09-11-2002, 02:12 AM
|
#2
|
Member
Registered: Mar 2002
Location: South UK
Distribution: Mandrake 8.2
Posts: 103
Rep:
|
What is it you're trying to do? Create a pdf?
|
|
|
09-11-2002, 02:13 AM
|
#3
|
Senior Member
Registered: Dec 2001
Location: The Netherlands
Distribution: Ubuntu
Posts: 1,316
Rep:
|
If you use a program to convert text files to pdf files then this can easily be done.
You could download txt2pdf from http://www.sanface.com
The program is shareware though. I don't know if there are any totally free versions out there.
Then you could do something like:
ls *.txt | xargs txt2pdf
|
|
|
09-11-2002, 07:15 AM
|
#4
|
Member
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747
Original Poster
Rep:
|
sorry...
it was much vague..
i wanted to copy abc.a => abc.b
for all *.a files in a directory..
thank you
|
|
|
09-11-2002, 08:04 AM
|
#5
|
Member
Registered: Aug 2002
Location: Mumbai,India
Distribution: Linux Mint 12, Gentoo
Posts: 230
Rep:
|
|
|
|
09-11-2002, 12:09 PM
|
#6
|
LQ Newbie
Registered: Jul 2002
Posts: 10
Rep:
|
If you're just trying to convert the extension, here you go:
ls *.txt |while read oldname;do
newname=`echo $oldname |sed 's/.txt/.pdf/'`
mv $oldname $newname
done
Enjoy,
Matt
|
|
|
09-12-2002, 01:51 PM
|
#7
|
Member
Registered: Mar 2002
Location: ma
Distribution: slackware
Posts: 747
Original Poster
Rep:
|
k.. thx..
i was wondering if i can do that without writing scripts ..(just with options )
thank you anyway..

|
|
|
09-12-2002, 05:05 PM
|
#8
|
Member
Registered: Sep 2002
Location: York, UK
Distribution: Debian Sid
Posts: 215
Rep:
|
I believe that the 'rename' command might do that for you. I remember being frustrated because I try to use it to do a simple renaming (as you would with mv), but it's actually more powerful than that.
|
|
|
09-13-2002, 07:21 AM
|
#9
|
Member
Registered: Aug 2002
Location: Mumbai,India
Distribution: Linux Mint 12, Gentoo
Posts: 230
Rep:
|
Quote:
Originally posted by Faecal
I believe that the 'rename' command might do that for you. I remember being frustrated because I try to use it to do a simple renaming (as you would with mv), but it's actually more powerful than that.
|
Thanks Faecal for the info. It was really a new information for me.
I was checking the command but in between I noticed an interseting thing
$ls
a.txt b.txt c.txt
$rename .txt .pdf *.txt
$ls
a.pdf b.pdf c.pdf
$rename *.pdf *.txt *.pdf
$ls
b.txt c.txt
Where is a.txt ??????????????? 
|
|
|
09-13-2002, 07:56 AM
|
#10
|
Member
Registered: Sep 2002
Location: York, UK
Distribution: Debian Sid
Posts: 215
Rep:
|
I was able to reproduce that problem. Your second use of rename is incorrect -
$rename *.pdf *.txt *.pdf
$rename .pdf .txt *.pdf
Remember, it's only in the last argument that you're specifying a group of files. The first two are simply text to be searched for and replaced.
That odd behaviour where one file is lost only occurred for me when I used your incorrect command. I cannot explain the mechanism that led to the loss of the file, but it's not important, since the command with the extra asterisks shouldn't have worked properly anyway.
|
|
|
09-13-2002, 08:35 AM
|
#11
|
Member
Registered: Aug 2002
Location: Mumbai,India
Distribution: Linux Mint 12, Gentoo
Posts: 230
Rep:
|
Ok I know that I have used the "so -called" wrong syntax for the command rename. But Does anybody know where had the file a.pdf gone and why did it happen to that file only? 
|
|
|
09-14-2002, 01:08 AM
|
#12
|
Member
Registered: Nov 2001
Location: US
Distribution: Slackware 14.2
Posts: 375
Rep: 
|
Quote:
Originally posted by doublefailure
k.. thx..
i was wondering if i can do that without writing scripts ..(just with options )
thank you anyway..
|
If you want a gui, krename comes with pretty high praise.
Speck
|
|
|
All times are GMT -5. The time now is 03:19 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|