corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Batch File Gurus


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Batch File Gurus
pow
Premium Member

Avatar

Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
4th Jun 08 at 13:49   View Garage View User's Profile U2U Member Reply With Quote

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
4th Jun 08 at 13:55   View User's Profile U2U Member Reply With Quote

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
4th Jun 08 at 13:58   View User's Profile U2U Member Reply With Quote

for /f "tokens=1 delims= " %%a in (list.txt) do copy documenttobecopied.doc %%a.doc
pow
Premium Member

Avatar

Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
4th Jun 08 at 14:35   View Garage View User's Profile U2U Member Reply With Quote

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
4th Jun 08 at 17:09   View User's Profile U2U Member Reply With Quote

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

Avatar

Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
5th Jun 08 at 10:19   View Garage View User's Profile U2U Member Reply With Quote

Thanks alot, i'll give it a go
pow
Premium Member

Avatar

Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
5th Jun 08 at 10:22   View Garage View User's Profile U2U Member Reply With Quote

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
5th Jun 08 at 10:33   View User's Profile U2U Member Reply With Quote

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

Avatar

Registered: 11th Sep 06
Location: Hazlemere, Buckinghamshire
User status: Offline
5th Jun 08 at 10:51   View Garage View User's Profile U2U Member Reply With Quote

Oh brilliant, thanks sooo much mate

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Batch file writing Skinz Geek Day 3 738
6th Jul 05 at 11:32
by loafofbrett
 
Autorun/Commands Dan Lewis Geek Day 2 432
20th Oct 06 at 13:18
by almost_me
 
Need to convert a batch file into VBScript Richie Geek Day 6 602
18th Oct 07 at 23:05
by Richie
 
Batch File help Dan Lewis Geek Day 6 247
23rd Nov 07 at 09:40
by Dan Lewis
 
AD / LDIFDE Guru's jamesw Geek Day 4 153
17th May 08 at 21:04
by jamesw
 

Corsa Sport » Message Board » Off Day » Geek Day » Batch File Gurus 29 database queries in 0.4076440 seconds