Results 1 to 5 of 5

Thread: Renaming all files

  1. #1

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772

    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.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    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.

  4. #4
    jim mcnamara
    Guest
    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

  5. #5

    Thread Starter
    Fanatic Member Wynd's Avatar
    Join Date
    Dec 2000
    Location
    In a bar frequented by colossal death robots
    Posts
    772
    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
  •  



Click Here to Expand Forum to Full Width