cisc
19-04-2003, 18:42
Ho fatto un programma in C che converte tutti i file, le directory e i file delle sottodirectory di una directory specificata da maiuscoli a minuscoli. il problema è che ai file delle sottodirectory non succede niente, nonostante siano scritti in maiuscolo!!!!
potete dare un'occhiata al codice e dirmi dove sbagli???
GRAZIE
#include <io.h>
#include <stdio.h>
#include <string.h>
main () {
void convert (char*);
char s [256];
printf ("VISUALIZZAZIONE DEL CONTENUTO DI UNA CARTELLA\n\ndirectory: ");
scanf ("%s",s);
convert (s);
scanf ("%s",s);
}
void convert (char *s) {
struct _finddata_t fd;
long int a;
char s1 [FILENAME_MAX];
char s2 [FILENAME_MAX];
char s3 [FILENAME_MAX];
if ((chdir(s))==0)
if ((a=_findfirst("*.*",&fd))!=-1)
{
strcpy (s2,fd.name);
strcpy (s1,strlwr (s2));
rename (s2,s1);
if(((fd.attrib & _A_SUBDIR ) == _A_SUBDIR) && (strcmp(fd.name, ".") != 0) && (strcmp(fd.name, "..") != 0))
{
strcpy (s3,s);
strcat (s3,s2);
convert (s3);
}
while (!_findnext (a,&fd)) {
strcpy (s2,fd.name);
strcpy (s1,strlwr (s2));
rename (s2,s1);
if(((fd.attrib & _A_SUBDIR ) == _A_SUBDIR) && (strcmp(fd.name, ".") != 0) && (strcmp(fd.name, "..") != 0))
{
strcpy (s3,s);
strcat (s3,s2);
convert (s3);}
}
}
_findclose (a);
}
potete dare un'occhiata al codice e dirmi dove sbagli???
GRAZIE
#include <io.h>
#include <stdio.h>
#include <string.h>
main () {
void convert (char*);
char s [256];
printf ("VISUALIZZAZIONE DEL CONTENUTO DI UNA CARTELLA\n\ndirectory: ");
scanf ("%s",s);
convert (s);
scanf ("%s",s);
}
void convert (char *s) {
struct _finddata_t fd;
long int a;
char s1 [FILENAME_MAX];
char s2 [FILENAME_MAX];
char s3 [FILENAME_MAX];
if ((chdir(s))==0)
if ((a=_findfirst("*.*",&fd))!=-1)
{
strcpy (s2,fd.name);
strcpy (s1,strlwr (s2));
rename (s2,s1);
if(((fd.attrib & _A_SUBDIR ) == _A_SUBDIR) && (strcmp(fd.name, ".") != 0) && (strcmp(fd.name, "..") != 0))
{
strcpy (s3,s);
strcat (s3,s2);
convert (s3);
}
while (!_findnext (a,&fd)) {
strcpy (s2,fd.name);
strcpy (s1,strlwr (s2));
rename (s2,s1);
if(((fd.attrib & _A_SUBDIR ) == _A_SUBDIR) && (strcmp(fd.name, ".") != 0) && (strcmp(fd.name, "..") != 0))
{
strcpy (s3,s);
strcat (s3,s2);
convert (s3);}
}
}
_findclose (a);
}