Wednesday, 12 March 2014

Simple way to copy multiple files under windows

The problem was simple. I had to copy a whole lot of files (from a txt file) from one location to another in order to optimize file structure. I was thinking about using batch scripting but than I realized that the only thing I really need is to use copy.exe. So other stuff like opening file, reading it line by line, parsing the line could be done in some simple manner. So I choose python that I haven't used since collage and give it a try. Phython is simple and all you need to do is just install execution environment, write a couple of line of code and It should work just fine.

So my input was:
154612818,28/21/BucenvstopvnovoletopovsejSlovenijix201301011400x700000x351x413x.mp4,2013/01/01/BucenvstopvnovoletopovsejSlovenijix201301011400x700000x351x413x.mp4
154612866,28/71/PrviletosnjinovorojenecjeAnjurx201301011334x700000x351x413x.mp4,2013/01/01/PrviletosnjinovorojenecjeAnjurx201301011334x700000x351x413x.mp4
154612881,28/84/Praznovanjenovegaletaposvetux201301011407x700000x351x413x.mp4,2013/01/01/Praznovanjenovegaletaposvetux201301011407x700000x351x413x.mp4


So first i had to open the file, splice it to get source and destination file and than just call copy function under windows. This is the result:


You have to have the fil you want to read from saved under same location in order to script to work.

Just open cmd.exe and run command py maypythoncopy.py and wait a bit:)

No comments:

Post a Comment