pow
Premium Member
Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
|
Help!
If I wanted to copy a document 40 times using a batch file, easy giving a different name pulled from a list, how could I/could I do it?
|
jamesw
Member
Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
|
so copy the same document 40 times, but each of those 40 documents have different names that are in a list?
[Edited on 04-06-2008 by jamesw]
|
jamesw
Member
Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
|
for /f "tokens=1 delims= " %%a in (list.txt) do copy documenttobecopied.doc %%a.doc
|
pow
Premium Member
Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
|
Yes.
Excel document needs to be named after each of the pupils in the yeargroup? will that work?
Thanks
|
jamesw
Member
Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
|
yes below will work fine, where the file you are wanting to copy is called master.xls, and the list is called pupils.txt this also presumes the list is just a text file with an entry on each line, is this the case, or are you using a csv file? Tweak it slightly as the above one would only have used there first name
for /f "tokens=1 delims=" %%a in (pupils.txt) do copy master.xls "%%a.xls"
|
pow
Premium Member
Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
|
Thanks alot, i'll give it a go
|
pow
Premium Member
Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
|
C:\Users\David Powell\Desktop\Temp>for /f "tokens=1 delims=" %%a in (pupils.txt)
do copy master.xlsx "%%a.xlsx"
%%a was unexpected at this time.
Using Office 07 hence xlsx
Whats going wrong?
|
jamesw
Member
Registered: 28th Jun 02
Location: Station Town, County Durham
User status: Offline
|
Its because its been ran direct from command prompt rather than a batch file. To get it to work from command prompt just need to trim some % of, the below should work direct from command prompt
for /f "tokens=1 delims=" %a in (pupils.txt) do copy master.xlsx "%a.xlsx"
if you still get stuck im on msn - james@arnisoncruise.co.uk
|
pow
Premium Member
Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
|
Oh brilliant, thanks sooo much mate
|