I was wondering if anyone out there would know how to do the following in perl?
I have multiple images taken from a webcam and need to rename them. There is over 200 images.
Each file is named 'filename1234 (1).jpg","filename1234 (2).jpg" and so on. Does anyone know a way to quickly get rid of the parens so I could get these sequentialy?
your help is greatly appreciated(sp)
Thanks
Perl help
Well, here's a way to do it from a bash command line:
Code: Select all
for i in *; do mv $i `echo $i | tr -d '(' | tr -d ')'`; done
Chevy's?byrdman wrote:thanks, void!!
I owe you lunch, that worked!! Once again, you proved you are 'The One.'

Of course there are a bazillion ways to do what you wanted. Maybe this would be a good thread for everyone to throw in other ways of doing it. Here's another bash way:
Code: Select all
for i in *;do j=${i/(/};mv $i ${j/)/};done
Ok, this is the last attempt of having you solve my perl ignorance with out me looking it up myself. I have another folder with a bunch of webcam pix that need the last 9 characters before the .jpg shaved off. Could you help me with that one?
This --> IMG-CH00-200304031400-3456-544.jpg
Should be -> IMG-CH00-200304031400.jpg
and for extra credit
shaving off the first 9 also to be
200304031400.jpg
This --> IMG-CH00-200304031400-3456-544.jpg
Should be -> IMG-CH00-200304031400.jpg
and for extra credit
shaving off the first 9 also to be
200304031400.jpg
Again, one of many ways, certainly not the shortest:
a little shorter but still using sed:
Code: Select all
for i in *;do mv $i `echo $i | sed "s/IMG-CH00-\(............\).*/\1.jpg/"`; done
Code: Select all
for i in *;do mv $i `echo $i | sed "s/.\{9\}\(.\{12\}\).\{9\}/\1/"`; done