I need to copy a set of files from their original location to a new folder

73 views Asked by At

I’m starting a project that requires assembling files and linking them to around 140 lines in a pdf table of contents (one file per line). The thing is that I have to do this 80 times and it seems very tedious to do it manually each time.

The TOC already exists, and I would like each line item to link to a corresponding pdf. (The link is alreay there, it's just that the pdf doesn't yet exist in that location). The pdf's already exist elsewhere and have predictable file paths (that change with project number).

If I have a list of files corresponding to each line item and their corresponding path, is it possible to write a script that copies the file in its original location and places the copy in the new location? (If so, how, and what is the best language to use?)

Thanks!

1

There are 1 answers

0
abma On

you can do it in Java, you might have to use a library like apache.commons:

    File sourceFile = new File(source);
    File targetFile = new File(target);
    FileUtils.copyFile(sourceFile, targetFile);