|
-
Mar 22nd, 2002, 08:05 PM
#1
Thread Starter
Fanatic Member
Renaming all files
I have about 150 files in a directory. How can I rename all them in a loop? (Ex: 1.mp3, 2.mp3, etc.)
Alcohol & calculus don't mix.
Never drink & derive.
-
Mar 23rd, 2002, 03:47 PM
#2
transcendental analytic
include <stdio.h>
...
for(...){
...
result=rename(old,new);
..}
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
Mar 23rd, 2002, 08:34 PM
#3
Thread Starter
Fanatic Member
I know that part, but I don't know all the file names. What I want to do is this:
1. Get first file name
2. Rename to i.mp3
3. i++
4. Get next file
...and so on until all files have been renamed. I know you can do this in PHP.
Alcohol & calculus don't mix.
Never drink & derive.
-
Mar 23rd, 2002, 10:32 PM
#4
Code:
HANDLE f;
WIN32_FIND_DATA g;
TCHAR h = "c:\whatever\*.*";
LPWIN32_FIND_DATA gptr = g;
f=FindFirstFile(h,g);
// you now have a file name in g.cFileName
// find the rest of the files
while(FindFileNext(f,g) ){
// process your next file name here
}
FindClose(gptr);// do this or risk a crash of the PC later on
-
Mar 24th, 2002, 02:51 PM
#5
Thread Starter
Fanatic Member
Thanks for the help
Alcohol & calculus don't mix.
Never drink & derive.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|