>>>>> "Reuben" == Reuben D Budiardja <[EMAIL PROTECTED]> writes:
> Hi, I need a bit of help with bash here. I try to create a > script that would change the extension of files in directory. I > have files like xxx.pc that I want a change to xxx.jpg, where > xxx is numbers, in a directory. How can I do that using bash? > thanks for any help. Reuben D.B. Like this: #!/bin/bash # rfe # --- # Renaming file extensions. # # rfe old_extension new_extension # # Example: # To rename all *.gif files in working directory to *.jpg, # rfe gif jpg ARGS=2 E_BADARGS=65 if [ $# -ne $ARGS ] then echo "Usage: `basename $0` old_file_suffix new_file_suffix" exit $E_BADARGS fi for filename in *.$1 # Traverse list of files ending with 1st argument. do mv $filename ${filename%$1}$2 # Strip off part of filename matching 1st argument, # then append 2nd argument. done exit 0 You may be interested in the Advanced Bash Scripting Guide available on the Linux Documentation Website: http://www.linuxdoc.org/LDP/abs/html/ Regards, Gregg ======================================================================== He who wonders discovers that this in itself is wonder. -- M. C. Escher _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list