Jump to content



Photo

Copy list using csv/txt file.

Answered Go to the full post

  • Please log in to reply
10 replies to this topic

#1 StrikedOut

StrikedOut

    Outside the box

  • Joined: 09-December 08
  • Location: Southampton

Posted 20 January 2014 - 14:25

Hi All.

 

At some point in the coming months I may be asked to copy a large number of small photos from a folder to be sent to one of our clients. My problem is that it will be thousands out of around 2.5m and will be given to me in a list, probably a csv or txt file. Normally I would use Robocopy to copy this number of files but it doesn't look like it is a viable answer due to it not being a . Is there a copy tool that I can use to copy files listed in a csv/txt file to a new source?

 

Thanks for the help.



Best Answer +BudMan , 21 January 2014 - 13:56

not sure why you would want to use robocopy in this use case? I am a fan of it to be sure, but wouldn't it be easier to use a command that supports a file list directly?

Are you putting that command in a batch file and running it, or just using it on the command line? So if you put it in a file you would need to change to %% vs %

Question - are all the files in the sources folder, no sub folders? So there are 2.5 million files in this one folder? Do any of these files have spaces in the names?

So I did a test without any spaces in names or subfolders.



So my list.txt is in c:\temp the folder I was actually running the command from - you need the () around it. Off the top not sure how you could get around sub folders in your source? Spaces in the names you might be able to get around with "'s in the textfile and using /F tokens= option..

Other than that you could have lists and run the command for every source folder... But as you can see list.txt is just list of the file names. Go to the full post



#2 +Nik L

Nik L

    Where's my pants?

  • Tech Issues Solved: 2
  • Joined: 14-January 03

Posted 20 January 2014 - 14:39

Create a batch file from the list?



#3 sc302

sc302

    Neowinian Senior

  • Tech Issues Solved: 28
  • Joined: 12-July 05
  • Location: NJ, USA

Posted 20 January 2014 - 14:41

sure. notepad++

 

Press CTRL-H to bring up the Find/Replace Dialog. Choose the "Regular expressions" checkbox near the bottom of the dialog.

To add "copy " to the beginning of each line, type ^ in the "Find what" field, and "copy " in the "Replace with" field. Then hit "Replace All".

 

then either copy and paste the contents into a batch file or save it as a batch file.

Enjoy.

 

 

 



#4 OP StrikedOut

StrikedOut

    Outside the box

  • Joined: 09-December 08
  • Location: Southampton

Posted 20 January 2014 - 16:51

Thanks sc302

 

Had to modify to ^(.) and Copy \1 for it to work otherwise it returned an error, "The regular expression to search is formed badly" when I hit replace all.

 

Now I have a list that starts Copy Test1.txt, how do I amend it to then include a destination?

 

I have also been looking at Robocopy again as it does seem to have the ability to state the files to copy but I cant get the syntax correct.

 

From Robocopy /? - file :: Files(s) to copy (names/wildcards: default is (*.*).

 

It only copies the last file I list.



#5 sc302

sc302

    Neowinian Senior

  • Tech Issues Solved: 28
  • Joined: 12-July 05
  • Location: NJ, USA

Posted 20 January 2014 - 21:53

I believe if you change the ^ to a $ that will allow you to modify the end.

#6 stumper66

stumper66

    Neowinian

  • Joined: 08-January 09
  • Location: Dallas, TX, USA

Posted 20 January 2014 - 23:48

if you have just the file names in a list, you can do something like this:

 

FOR /F %I IN (list.txt) DO robocopy c:\mysourcefolder \\destnetworkserver\destfolder %I



#7 OP StrikedOut

StrikedOut

    Outside the box

  • Joined: 09-December 08
  • Location: Southampton

Posted 21 January 2014 - 09:05

Thanks sc302, I will look into how this will work but it should be ok.

 

Stumper66, tried your method with the following,

 

C:\Users\........\COPY TEST>FOR /F %I IN test.txt DO robocopy "C:\Users\........\COPY TEST\Source" "C:\Users\.........\COPY TEST\Destination" %I
 
And got this with no files copied,
 
test.txt was unexpected at this time.
 
What should the test.txt look like? Currently I have tried one entry per line and all on same line separated with a comma but neither work. I also had the test.txt file in both the COPY TEST folder and the source folder and it doesn't seem to like it.


#8 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 96
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 21 January 2014 - 13:56   Best Answer

not sure why you would want to use robocopy in this use case? I am a fan of it to be sure, but wouldn't it be easier to use a command that supports a file list directly?

Are you putting that command in a batch file and running it, or just using it on the command line? So if you put it in a file you would need to change to %% vs %

Question - are all the files in the sources folder, no sub folders? So there are 2.5 million files in this one folder? Do any of these files have spaces in the names?

So I did a test without any spaces in names or subfolders.

testofcommand.png

So my list.txt is in c:\temp the folder I was actually running the command from - you need the () around it. Off the top not sure how you could get around sub folders in your source? Spaces in the names you might be able to get around with "'s in the textfile and using /F tokens= option..

Other than that you could have lists and run the command for every source folder... But as you can see list.txt is just list of the file names.

#9 OP StrikedOut

StrikedOut

    Outside the box

  • Joined: 09-December 08
  • Location: Southampton

Posted 21 January 2014 - 15:59

Perfect (almost) Budman.

 

All photos are in the single folder, no subfolders and no gap in names.

 

I had attempted the command earlier but didn't include the ()'s so hit an error, didn't occur to me they were required.

 

I also added /LOG+:log.txt but the log creates an entry for each file copied appended to a single file, do you know if it can be modified to show a summary for all in one entry?



#10 +BudMan

BudMan

    Neowinian Senior

  • Tech Issues Solved: 96
  • Joined: 04-July 02
  • Location: Schaumburg, IL
  • OS: Win7, Vista, 2k3, 2k8, XP, Linux, FreeBSD, OSX, etc. etc.

Posted 22 January 2014 - 17:51

Summary would work if it was one robocopy command, but the way that loop works is your calling robocopy each copy, that my point of maybe using something else that supports lists (off the top not sure what).

But in this case your just looping a call of robocopy source dest file, each time.. So sure you could append to the same file, but see in my above screen shot how you get a summary of the dig copy, above that is the summary of each file that was copied before.

If you copied all the files in one call of robocopy then you would get a summary of what robocopy did.

As to 2.5m files in 1 folder -- man that must take for ever to come up in explorer ;)

#11 OP StrikedOut

StrikedOut

    Outside the box

  • Joined: 09-December 08
  • Location: Southampton

Posted 22 January 2014 - 20:13

No problem.

If and when they want the pictures and the log they can use CTRL+F to see if the file they are looking for has copied.

I asked them to change the structure to one folder per month but for what ever the reason was it didn't happen. The previous 2003 R2 box used to completely hang if we tried to do anything with this folder, even a simple right click!

Thanks again, we are going to test this with a large number of files and see how it copes but what I have been testing with so far works perfectly.