Re: [ccp4bb] changing names of many files
I don't know where this comes from, but its called rename-alot. Its a perl script. I'm guessing Larry is Larry Wall, but who knows. chmod a +x it and then put it in your path (~/bin) You run it like this rename-alot 's/1105 A/A/' *.osc The above will change all files that look like this: 1105 A0176.osc to this A0176.osc. The script is everything between, but not including, the equals signs. Your system probably has perl on it unless you are running Mac OS 9 or prior or any version of Windows. == #!/usr/bin/perl -w # rename - Larry's filename fixer $op = shift or die Usage: rename-alot expr [files]\n . eg: % rename-alot \'s/abc /abc-/\' abc*txt\n ; chomp(@ARGV = STDIN) unless @ARGV; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } == James On Mar 11, 2008, at 6:32 PM, Raja Dey wrote: Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 Chat on a cool, new interface. No download required. Click here. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com
Re: [ccp4bb] changing names of many files
There's a dead-ordinary linux command 'rename': rename 1055 '' 1055*.osc Saved my butt numerous times. phx. James Stroud wrote: I don't know where this comes from, but its called rename-alot. Its a perl script. I'm guessing Larry is Larry Wall, but who knows. chmod a+x it and then put it in your path (~/bin) You run it like this rename-alot 's/1105 A/A/' *.osc The above will change all files that look like this: 1105 A0176.osc to this A0176.osc. The script is everything between, but not including, the equals signs. Your system probably has perl on it unless you are running Mac OS 9 or prior or any version of Windows. == #!/usr/bin/perl -w # rename - Larry's filename fixer $op = shift or die Usage: rename-alot expr [files]\n . eg: % rename-alot \'s/abc /abc-/\' abc*txt\n ; chomp(@ARGV = STDIN) unless @ARGV; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } == James On Mar 11, 2008, at 6:32 PM, Raja Dey wrote: Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 Chat on a cool, new interface. No download required. Click here. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com
Re: [ccp4bb] changing names of many files
for me following works (just an example): The objective was to remane all 336 images files to 760D6a0001(to 336).img to 760D6a0_001(to _336).img Just save the script below (like filename.com) and run as sh filename.com *** for i in 760D6a0***.img do mv $i ${i%760D6a0***}760D6a0_${i#760D6a0} done Rajesh On Wednesday 12 March 2008 02:32, Raja Dey wrote: CCP4BB@jiscmail.ac.uk -- Rajesh Kumar Singh, PhD Institut fur Biochemie Universitat Greifswald Felix-Hausdorff-Str. 4 D-17489 Greifswald Germany E.Mail: [EMAIL PROTECTED] Phone: +49-3834- 86 4392
Re: [ccp4bb] changing names of many files
Just for the sake of completeness: mmv is also a package available for some linux distributions (SuSE at least), so you don't need the alias. If you like doing so using shell features, you could, with bash, issue for i in 1105\ A*; do mv $i ${i#1105\ } ; done This might work in many POSIX-sh-compliant shells, not only bash (which the obsolete (t)csh is not ;- ) Cheers, Tim -- Tim Gruene Institut fuer anorganische Chemie Tammannstr. 4 D-37077 Goettingen GPG Key ID = A46BEE1A On Wed, 12 Mar 2008, Raja Dey wrote: Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 - Chat on a cool, new interface. No download required. Click here.
Re: [ccp4bb] changing names of many files
Beware that 'rename' on Fedora/Redhat and the like works differently from 'rename' on Debian/Ubuntu etc. Both are in /usr/bin but the former is an executable and the latter is a Perl script (it's apparently installed with Perl), and is probably descended from your 'rename-alot' (the syntax appears to be identical). Personally I think the Debian/Perl version is much more powerful, i.e. you can do anything that's allowed by the Perl regexp rules. For example the executable version only changes the *first* occurrence of a search string, whereas with the 's/.../.../g' modifier you can change multiple occurrences (assuming that's what you want of course!). -- Ian -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Frank von Delft Sent: 12 March 2008 07:42 To: James Stroud Cc: CCP4BB@JISCMAIL.AC.UK Subject: Re: [ccp4bb] changing names of many files There's a dead-ordinary linux command 'rename': rename 1055 '' 1055*.osc Saved my butt numerous times. phx. James Stroud wrote: I don't know where this comes from, but its called rename-alot. Its a perl script. I'm guessing Larry is Larry Wall, but who knows. chmod a+x it and then put it in your path (~/bin) You run it like this rename-alot 's/1105 A/A/' *.osc The above will change all files that look like this: 1105 A0176.osc to this A0176.osc. The script is everything between, but not including, the equals signs. Your system probably has perl on it unless you are running Mac OS 9 or prior or any version of Windows. == #!/usr/bin/perl -w # rename - Larry's filename fixer $op = shift or die Usage: rename-alot expr [files]\n . eg: % rename-alot \'s/abc /abc-/\' abc*txt\n ; chomp(@ARGV = STDIN) unless @ARGV; for (@ARGV) { $was = $_; eval $op; die $@ if $@; rename($was,$_) unless $was eq $_; } == James On Mar 11, 2008, at 6:32 PM, Raja Dey wrote: Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 Chat on a cool, new interface. No download required. Click here. -- James Stroud UCLA-DOE Institute for Genomics and Proteomics Box 951570 Los Angeles, CA 90095 http://www.jamesstroud.com Disclaimer This communication is confidential and may contain privileged information intended solely for the named addressee(s). It may not be used or disclosed except for the purpose for which it has been sent. If you are not the intended recipient you must not review, use, disclose, copy, distribute or take any action in reliance upon it. If you have received this communication in error, please notify Astex Therapeutics Ltd by emailing [EMAIL PROTECTED] and destroy all copies of the message and any attached documents. Astex Therapeutics Ltd monitors, controls and protects all its messaging traffic in compliance with its corporate email policy. The Company accepts no liability or responsibility for any onward transmission or use of emails and attachments having left the Astex Therapeutics domain. Unless expressly stated, opinions in this message are those of the individual sender and not of Astex Therapeutics Ltd. The recipient should check this email and any attachments for the presence of computer viruses. Astex Therapeutics Ltd accepts no liability for damage caused by any virus transmitted by this email. E-mail is susceptible to data corruption, interception, unauthorized amendment, and tampering, Astex Therapeutics Ltd only send and receive e-mails on the basis that the Company is not liable for any such alteration or any consequences thereof. Astex Therapeutics Ltd., Registered in England at 436 Cambridge Science Park, Cambridge CB4 0QA under number 3751674
Re: [ccp4bb] changing names of many files
This is also easily done using midnight commander. http://en.wikipedia.org/wiki/Midnight_Commander http://linuxgazette.net/issue23/wkndmech_dec97/mc_article.html Here are the details on changing names. http://www.chm.tu-dresden.de/edv/mc/mc4.5/manual1.html#45
[ccp4bb] changing names of many files
Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 - Chat on a cool, new interface. No download required. Click here.
Re: [ccp4bb] changing names of many files
Install zsh. Then invoke it. Then issue: autoload -U zmv alias mmv='noglob zmv -W' Then you are ready for some fun: mmv 1105\ A*.osc A*.osc Then if you decide to make your default shell zsh, you can put that in your .zshrc file and all you have to remember in the future is mmv Raja Dey wrote: Hi, How I can change names of many files keeping the extension same. My files are like this 1105 A0176.osc 1105 A0177.osc 1105 A0178.osc 1105 A0179.osc 1105 A0180.osc I want to change them as A0176.osc A0177.osc A0178.osc A0179.osc A0180.osc I am using ubuntu linux. Thanks... RD Raja Dey, Ph.D. Research Associate Molecular and Computational Biology University of Southern California 1050 Childs Way, Los Angeles, CA 90089 - Chat on a cool, new interface. No download required. Click here.