Jump to content

Looking for program that copies files using a CSV file list

I have use case where I we have a list of files in a CSV file, and we need to be able to copy those files to a location on the network. 

 

I am looking for a file-copy program that I can provide this CSV file to, and that program will copy all of the files to a location of the user's choice. I prefer to stay away from PowerShell scripts because this isn't an "IT task". Instead, something I want an end-user on our network to be able to do themselves without assistance from IT.

 

We have an easy way for them to produce a CSV file. We just want to provide them an easy way to import that CSV file a file-copy program that's easy for them to use/understand. 

 

Please assume we have an easy way for the user to generate a CSV file with a file list. And, that we can amend the format of the CSV file to whatever schema/format the file-copy software requires.

 

Any experience / ideas?

Link to comment
Share on other sites

Link to post
Share on other sites

35 minutes ago, TimD said:

I prefer to stay away from PowerShell scripts because this isn't an "IT task"

then make the powershell script for them? you're not gonna find some out the box solution that'll accept the exact form of CSV that your exports produce.

Link to comment
Share on other sites

Link to post
Share on other sites

A CSV file is   "comma separated values", meaning  values on one line, separated by comma. 

 

You probably mean one file path / filename per line or something like that.

 

For me, easiest would be to write a php script and then launch it  with a php.exe  script.php 

 

php has built-in functions for copying files and lots of other things ... script would be something like this :

 

<?php 

$ENTER = chr(0x0D).chr(0x0A);
$destination = 'c:/temp/'; // Windows can work with either \ or /

$filelist_text = file_get_contents('c:/temp/list.txt'); // read the contents of the file in memory

$filelist = explode($ENTER , $filelist_text); // split the text file into an array, one filename per line

foreach ($filelist as $file) { 
  if ($file!='') { // don't try to process empty text lines
    // https://www.php.net/manual/en/function.pathinfo.php
    $parts = pathinfo($file); // split the filename into path, name, extension etc 
    // https://www.php.net/manual/en/function.copy.php
    copy($file, $destination.$parts['basename']);
  }
}

?>

The script strips the path from the input, if you want to preserve folders  ex you want to copy c:\temp\a.txt and c:\temp\extra\b.txt  then you need to tweak the script and make sure the folders exist at the destination  (for ex try to create the extra folder at the destination before copying the second file)

 

Link to comment
Share on other sites

Link to post
Share on other sites

To add ... it's not a straight copy, but it could be helpful.

 

Programs that compress files have command line options to load list of files to be compressed from a file list (a text file with one file or folder per line)

 

For example, 7zip has a command line compressor, you'd type something like

 

7z.exe a -mx0 c:\temp\archive.7z  @c:\temp\filelist.txt

 

a means add files to an archive,  -mx0 means set compression level 0 (store uncompressed) - there's levels from 1 to 9 -  , then where to create the archive and last parameter, location of the list of files with "@" in front.

 

WinRAR also has a command line compressor:

 

rar.exe a -m0 c:\temp\archive.rar @c:\temp\filelist.txt

 

same deal, a means add to archive,  -m sets compression level to 0 (store, no compression) , followed by archive location and list of files.

 

Then you can just grab the archive and unpack it where you want the files.

 

 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×