raab
03-22-2002, 09:45 PM
I have about 150 files in a directory. How can I use a loop to rename each file to the current counter value (ex: 1.mp3, 2.mp3, etc)?
|
Click to See Complete Forum and Search --> : Renaming all files in a directory raab 03-22-2002, 09:45 PM I have about 150 files in a directory. How can I use a loop to rename each file to the current counter value (ex: 1.mp3, 2.mp3, etc)? Gnu/Vince 03-22-2002, 10:10 PM I had made a script like that a while back, search the boards. spiffgq 03-23-2002, 04:43 PM try something like this for i in * do mv $i rename$i #modify this line done This will iterate over all files returned by calling ls * and store each file (one at a time) in the variable i. raab 03-23-2002, 09:49 PM Too bad I can't use those, I was on a windows box when I posted that actually. Thanks for the help anyway though :) I will keep those for future reference. I managed to do it there using a PHP script on Apache. I was looking for C or C++ though which is why I asked here if anyone's wondering ;) [ 23 March 2002: Message edited by: raab ] norm 03-24-2002, 12:06 AM this may help www.linuxselfhelp.com/HOWTO/Bash-Prog-Intro-HOWTO-12.html#ss12.1 (http://www.linuxselfhelp.com/HOWTO/Bash-Prog-Intro-HOWTO-12.html#ss12.1) null TacKat 03-24-2002, 10:26 AM You can make a *.bat file in windows to do it for you. It's been too long since I've had to do that so I can't really help though. You could do it in C or C++, but that's really much more complexity than you need. kmj 03-24-2002, 11:55 AM <STRONG> I was looking for C or C++ though which is why I asked here if anyone's wondering ;) </STRONG> next time remember to ask that ahead of time. We use various and sundry (is that redundant?) different languages here; and you'll get a response for every language unless you mention the specific language. :D jscott 03-24-2002, 12:31 PM Originally posted by kmj: <STRONG>We use various and sundry (is that redundant?) </STRONG> Why, yes, it is: sun·dry adj. Various; miscellaneous: a tarball containing *.c, *.pl, and sundry items. raab 03-24-2002, 04:15 PM Originally posted by kmj: <STRONG>next time remember to ask that ahead of time. We use various and sundry (is that redundant?) different languages here; and you'll get a response for every language unless you mention the specific language. :D</STRONG> I'll remember that :) takshaka 03-25-2002, 07:39 PM Originally posted by raab: Too bad I can't use those, I was on a windows box when I posted that actually. I'm sure many of us run Perl, Python and bash (among others) under Windows. justlinux.com
Copyright Internet.com Inc. All Rights Reserved. |