Aug-09-2020, 04:05 AM
Maybe I don't understand the problem, but I thought you have a file containing filenames.
I suppose you could use two loops. A loop to read all the file names and then a second loop to read the destination directory and do the copy. These loops would be one after the other, not one nested inside another. Heck, you could use three loops if you wanted; read names, read paths, do copy/rename. But why use 2 or 3 loops when one loop is faster and makes the most sense. One loop with a series of tasks that are performed for each loop iteration.
Quote:name1And you also have file containing file paths.
name2
name3
Quote:path1And that you want to use the names and paths to copy files from a source folder to different destination folders.
path2
path3
Quote:copy source_dir/name1 to path1/name1If this is correct I see no reason for two loops. In one loop you could read the filename, read the desination directory and dp tje file copy (or rename).
copy source_dir/name2 to path2/name2
copy source_dir/name3 to path3/name3
I suppose you could use two loops. A loop to read all the file names and then a second loop to read the destination directory and do the copy. These loops would be one after the other, not one nested inside another. Heck, you could use three loops if you wanted; read names, read paths, do copy/rename. But why use 2 or 3 loops when one loop is faster and makes the most sense. One loop with a series of tasks that are performed for each loop iteration.