I once had a script that would do the following. It would rename part of a filename of multiple files in the current directory:
For example:
rename variable1 variable2
rename 456 555
Input:
testa456testa
sama456sama
apple456applea
johna_456_johna
davida_456_davidb
Output:
testa555testa
sama555sama
apple555applea
johna_555_johna
davida_555_davidb
I don't have the script anymore, and I am still new to Unix. I need a script, that I can use from the command line.
What I do now is:
I list the files "ls * (file names)" to a temp file name. Then I do a search %/s/456/555/g. Then I move all old file names, to new file names. I was able to do this in a command line "rename $1 to $2". So, in any given directory I would line to rename middle of file names from a command line. It could be hundreds of files. Hope this make sense, Thanks Ivan
456
to555
? Please edit your text to include a question. And while you're there please tell us your UNIX flavour or Linux distribution.rename
script?