[Tutor] Copy script

Anthony Baldwin tonytraductor at linguasos.org
Thu Apr 10 04:30:36 CEST 2008


Alan Gauld wrote:
> "Que Prime" <queprime at gmail.com> wrote
>
>   
>> I have a folder of 150,000 pdf files and I need to copy 20,000 of 
>> them to
>> another folder.  The ones I need to copy are in a .txt file.
>>     
Assuming the text file is a list of those to be copied,
wouldn't a simple bash script do the trick?
(don't know about windows, but this would work on Mac or Linux,
and, I assume there must be a way to do this with a  windows command 
line script of some sort.)

#!/bin/bash

cd /path/to/dir/with/files/and/list

llistofiles=$(cat "your .txt file here")

echo "Copying files..."

for each i in $listofiles
do
cp $i /path/to/other/folder/$i

echo "All done...b'bye..."

exit

Or, perhaps with tcl

#!/usr/bin/wish

set listofiles [read "your txt file here"]

puts "Copying files..."

foreach a {$listofiles} {
file copy $a /path/to/target/dir
    }

puts "All done...b'bye..."

exit

I imagine python could do something quite similar,
but confess I am just lurking on this list and have barely begun
to learn python.

/tony

-- 
Anthony Baldwin

http://www.BaldwinLinguas.com 
Translation & Interpreting

http://www.TransProCalc.org 
Free translation project mgmt software 

http://www.LinguasOS.org 
Linux for Translators




More information about the Tutor mailing list