shragi
asked on
Script to make file copies with different names
I had a file named "testnow.txt" and i want to make this file 95 copies.. in the same folder
i want to duplicate the "testnow.txt" and rename it like
testnow_1.txt
testnow_2.txt
testnow_3.txt
.
.
.
.
testnow_95.txt
Here is the java code that made this work, but I am not sure how to write the same logic using perl.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class filerenametemp {
public static void main(String[] args) {
Path src = Paths.get("C:\\temp\\testn ow.txt");
for( int i=1;i<=6; ++i ){
Path dest = Paths.get("C:\\temp\\testn ow_" + i + ".txt");
try {
Files.copy(src,dest);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Can some one provide me the code with same logic in perl.
Thanks,
i want to duplicate the "testnow.txt" and rename it like
testnow_1.txt
testnow_2.txt
testnow_3.txt
.
.
.
.
testnow_95.txt
Here is the java code that made this work, but I am not sure how to write the same logic using perl.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
public class filerenametemp {
public static void main(String[] args) {
Path src = Paths.get("C:\\temp\\testn
for( int i=1;i<=6; ++i ){
Path dest = Paths.get("C:\\temp\\testn
try {
Files.copy(src,dest);
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Can some one provide me the code with same logic in perl.
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
never mind i got it - thanks
ASKER
what if my number is not always 95 and it changes based on parameter.
How do i change script for that.