prueba a ver si te vale este programa, solo tienes que compilar
/*********************************************************************/
/* */
/* Software: dupli.c */
/* Estado: Version 0 Release 0 Modif. 1 Patch 0 */
/* Copyright (C) 2010 LnkLst para BandaAncha.eu */
/* */
/* Funcion: Duplicar ficheros colocando un sufijo numerico */
/* */
/* Modificado: 16 Agosto 2010 Inicio */
/* */
/* This program is free software:you can redistribute it and/or */
/* modify it under the terms of the GNU General Public License as */
/* published by the Free Software Foundation,either version 2 of the */
/* License,or any later version. */
/* */
/* This program is distributed in the hope that it will be useful, */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
/* GNU General Public License for more details. */
/* You should have received a copy of the GNU General Public License */
/* along with this program.If not, see */
/* */
/* Este programa es Software Libre; Usted puede redistribuirlo y/o */
/* modificarlo bajo los terminos de la GNU Licencia Publica General */
/* (GPL) tal y como ha sido publicada por la Free Software Foundation*/
/* o bien la version 2 de la Licencia, o cualquier version posterior.*/
/* */
/* Este programa se distribuye con la esperanza de que sea util, */
/* pero SIN NINGUNA GARANTIA; tampoco las implicitas garantias de */
/* MERCANTILIDAD o ADECUACION A UN PROPOSITO PARTICULAR. */
/* Consulte la GNU General Public License (GPL) para mas detalles. */
/* Usted debe recibir una copia de la GNU General Public License(GPL)*/
/* junto con este programa; si no,lea */
/* */
/* Compilacion: */
/* - Linux x86 */
/* gcc -o */
/* Ej.- gcc -o dupli dupli.c */
/*********************************************************************/
#define VERSION "0.0.0.1"
#define PGMID "DUPLI"
/*Includes Estandard */
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/*Funciones*/
void GrabaHora(void);
/*Estructuras de tiempo*/
time_t lt;
struct tms bt1,bt2,bt3,bt4;
clock_t t1,t2,t3,t4;
int TPS=0; /*Ciclos de cpu*/
/*Contadores*/
int i=0;
/*Variables*/
char *FICHIN =0;
char *directorio=0;
long COPIAS = 0;
long ini=0;
char SALIDA[1024]= "\x0";
int RCI = 0;
int main(int argc, char **argv)
{
lt = time(NULL);
if (argc < 5)
{
printf("%.8s Uso:%s <\n",
ctime(<)+11,PGMID);
exit(0);
}
t1 = times(&bt1);
TPS = sysconf(_SC_CLK_TCK); /*obtengo los ciclos de cpu*/
//strncpy(FICHIN,argv[1],(long)strlen(argv[1]));
//strncpy(directorio,argv[2],(long)strlen(argv[2]));
FICHIN = (char *) argv[1];
directorio = (char *) argv[2];
ini = (long) atol(argv[3]);
COPIAS = (long) atol(argv[4]) + ini;
printf("%.8s %s Fichero a copiar:%s Directorio Destino:%s Numero de copias:%d Numero inicial.%d\n",
ctime(<)+11,PGMID,FICHIN,directorio,COPIAS-ini,ini);
for (i=ini;i (signo menor que) COPIAS;i++)
{
memset(SALIDA,'\x0',sizeof(SALIDA));
sprintf(SALIDA,"cp %s %s/%s.%i",FICHIN,directorio,FICHIN,i);
RCI = system(SALIDA);
if (RCI != 0)
{
printf("Error %i en copia %i de %s\n",RCI,i,FICHIN);
break;
}
else
{
printf("Copia %i OK de %s\n",i,FICHIN);
}
}
GrabaHora();
return 0;
}
/***---------------------------------------------------------***/
/***Funcion GrabaHora Estadisticas de T.CPU T.Elapsed--------***/
/***---------------------------------------------------------***/
void GrabaHora()
{
t2 = times(&bt2);
printf("T.CPU:%.2fs T.Elap:%.2fs\n",
(float)(bt2.tms_utime - bt1.tms_utime)/(float)TPS,\
(float)(t2 - t1)/(float)TPS);
return;
}