Ming
06-23-2001, 12:24 AM
I have a dir full of files with a .1 appended to the filename. How can I remove the .1 from all the filenames at once.
|
Click to See Complete Forum and Search --> : Mass file rename? Ming 06-23-2001, 12:24 AM I have a dir full of files with a .1 appended to the filename. How can I remove the .1 from all the filenames at once. Malakin 06-23-2001, 06:22 AM make a file with your favorite text editor called rmext with the following contents: #!/bin/sh # ls * | while read file do newname=$(echo $(basename $file '.1')) if [ "$file" != "$newname" ]; then mv $file $newname fi done Put this file in your "/usr/bin" directory. Then use this command on the file "chmod +x /usr/bin/rmext". I say to put it in your /usr/bin directory just because your path will point there and the chmod command makes the file executable. Then whatever directory you're in just type rmext and **all** the files in that directory that have .1 on the end will have .1 removed. So for example "xxx.1" will end up as "xxx" but "xxx.01" wouldn't change. justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |