slayer17
02-14-2001, 11:52 AM
Hey folks I am looking for a script that will change mulitiple file names in a dir. ie. mandrake_office.menu to redhat_office.menu. And help would be loved.
Happy V-Day,
slayer17
Happy V-Day,
slayer17
|
Click to See Complete Forum and Search --> : Need to change a lot of file names! slayer17 02-14-2001, 11:52 AM Hey folks I am looking for a script that will change mulitiple file names in a dir. ie. mandrake_office.menu to redhat_office.menu. And help would be loved. Happy V-Day, slayer17 X_console 02-14-2001, 05:13 PM I thought I'd leave this for some Perl guru to answer but seeing that no one else has posted, here's my version. I'm assuming that all of your files with "mandrake_"? So you have files like mandrake_foo.txt, mandrake_penguin.jpg, mandrake_essay.doc, and such right? This script will change "mandrake_" to "redhat_"... I call it, drake2hat :) #!/bin/bash printf "Directory to work on: " read dir if [ -z "$dir" ]; then exit 0; fi cd $dir for i in *; do suffix=$(echo $i | awk -F_ '{print $NF}') x="redhat_"$suffix mv $i $x done By the way, this will add redhat_ to any other files that don't start with mandrake_ So if you don't want that to happen, create a temporary directory (say ~/myTemp) and do "cp mandrake_* ~/myTemp) and run the script there. slayer17 02-15-2001, 05:26 PM Thanks alot man! I will let you know the outcome! slayer17 02-15-2001, 05:27 PM Thanks alot man! I will let you know the outcome! justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |