Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/syscall.h>
- #include <dirent.h>
- #include <string.h>
- int main()
- {
- DIR *dr = opendir("./");
- struct dirent *fl; //Struct para receber as informações do diretório
- int len;
- char ans[301];
- if(dr == NULL)
- {
- puts("ERROR");
- exit(0);
- }
- while( fl = readdir(dr) ) //Lê cada arquivo do diretório
- {
- strcpy( ans + 1, fl -> d_name ); //Copia o nome do arquivo pra uma var
- ans[0] = 'L'; //Add "L" antes do nome
- rename( fl -> d_name, ans); //Novo nome do arquivo
- }
- puts("DONE");
- exit(1);
- }
Advertisement
Add Comment
Please, Sign In to add comment