linux rename multiple files to same suffix
hi all
I do have mutliple files want to be renamed with same suffix. for example files start with 1ab, 1ac, 1ad .... and want them to rename them with same suffix like 1ab.dum 1ac.dum 1ad.dum... Is it any way to do that in linux with one command or script. Other question is to split the huge files with same suffix, I did used split command to split the file but it does not give me the suffix option. Thanks appreciate your help venkat |
For rename:
Code:
for filename in $(ls 1a*) |
Hi there
Thanks a lot, it works like a charm. I do have one more help to ask, I do have the 2000 files starting with random file prefix, I would like to change the prefix like dum_1.x dum_2.x, dum_3.x as a running numbers. Please let me know how can I do that , really apprecite. cheers venkat |
I'm sorry, I don't entirely understand what your asking.
Please provide a sample list of five or six file names giving the before and after names that you are trying to achieve. For example: Code:
Before: dum_1.x |
Something like this?
Before: teddy@lappy~/test$ ls halabuda.x yoda.y.x yoyo.x.y Code:
teddy@lappy~/test$ i=1; for filename in $(ls); do mv $filename $i.${filename##*.}; i=$((i+1)); done teddy@lappy~/test$ ls 1.x 2.x 3.y |
Quote:
Quote:
Code:
for file in 1a* #or for file in * |
Quote:
|
Quote:
eg usage Code:
# ls -1 |
Thanks a lot for the reply.
My problem is, I do have the files xxx.txt x12.txt x32.txt xaaa.txt x123c.txt x3432a.txt like variable prefix, I want to rename them entirely in prefix I want something like this mod_1.txt mod-2.txt mod_3.txt .... ..... .... mod_100000.txt I do have redhat5. Thanks for everyone trying to help me out venk |
why do you post the same question again without even trying ? what have you tried???
|
use grename or krename
|
Thanks a lot to every one. I did posted again because Disillunoist
need more details of what I need ? I did tried other script, but it did not change the prefix the way I want. I did tried $ i=1; for filename in $(ls); do mv $filename $i.${filename##*.}; i=$((i+1)); done That changes the number but it did not replace the prefix the way I want. I am not good in python so not sure what I could change in that script for change the prefix. Thanks a lot for the reply. Again I do have the files xxx.txt x12.txt x32.txt xaaa.txt x123c.txt x3432a.txt like variable prefix, I want to rename them entirely in prefix I want something like this mod_1.txt mod-2.txt mod_3.txt .... ..... .... mod_100000.txt Here I did change the suffix with numbers for identification, Thanks again for everyone trying to help me. |
Quote:
|
Code:
i=1 |
Code:
i=1 |
All times are GMT -5. The time now is 12:06 PM. |