There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
DOS/Other
Tag Cloud
access acer asus bios bsod computer crash desktop driver drivers error ethernet excel freeze gaming hard drive hardware hdmi internet laptop lcd malware memory modem monitor motherboard network printer problem ram registry repair router slow software sound toshiba trojan usb video virus vista wifi windows windows 7 windows 7 32 bit windows 7 64 bit windows xp wireless xbox
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/Other >
Batch file to copy files by filename

Reply  
Thread Tools
yoda_pooh's Avatar
Junior Member with 1 posts.
 
Join Date: Oct 2009
Experience: Beginner
09-Oct-2009, 03:51 PM #1
Batch file to copy files by filename
Hello,

I'm a teacher with about 800 students in my school. We have pictures of all students on a network drive, named xxxxxx.jpg where xxxxxx is their individual student number.

I want to use a batch file that will only copy the pictures of the 160 or so students I teach. I already have all of their student numbers in a spreadsheet.

Thank you
midders's Avatar
Account Closed with 654 posts.
 
Join Date: Dec 1969
09-Oct-2009, 05:45 PM #2
Using a spreadsheet formula, create a new column which evaluates to:
Code:
copy "\\server\path\0123456.jpg" "c:\My Documents\student pics"
where \\server\path is the path to your network share (could be mapped to a drive letter etc.)
Select the entire column and then save as a plain text file (newline separated) called something.bat
Create a new folder in My Documents called "student pics"
Click on Start->Run... and browse to your something.bat file. Click on OK.
Eh, voila it should be done.
If it doesn't work, check your quotes carefully; any path that includes spaces needs to be quoted. You can also run the something.bat file from the command line (Start->Run... cmd) to check for error messages, or add the word "pause" (no quotes) after the end of your list of copy commands in the something.bat file, so that you can view the results.

Slainte

midders
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
09-Oct-2009, 09:36 PM #3
That is one way to do it. I personally would just dump the excel file to a CSV and then parse the csv with a For Loop.
midders's Avatar
Account Closed with 654 posts.
 
Join Date: Dec 1969
10-Oct-2009, 04:08 PM #4
Quote:
Originally Posted by Squashman View Post
That is one way to do it. I personally would just dump the excel file to a CSV and then parse the csv with a For Loop.
I was going to suggest something along those lines, but using sed; however, with a self-proclaimed status of 'beginner' I thought that the simpler option was the way to go.
Squashman's Avatar
Trusted Advisor with 18,706 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: Bocks of Rox
10-Oct-2009, 10:41 PM #5
Posted via Mobile Device
SED???
No need to use SED. A basic batch file with a for loop will suffice just fine. Why were you thinking sed?
midders's Avatar
Account Closed with 654 posts.
 
Join Date: Dec 1969
11-Oct-2009, 02:47 AM #6
Quote:
Originally Posted by Squashman View Post
Posted via Mobile Device
SED???
No need to use SED. A basic batch file with a for loop will suffice just fine. Why were you thinking sed?
Just trying to keep old skills from going too rusty; you know you're a real nerd when you can write a sed pattern first time! I was tinkering with it for a complex renaming task a few days ago, so it's fresh in my mind.
PatrickMc's Avatar
Junior Member with 14 posts.
 
Join Date: Jun 2009
02-Nov-2009, 12:49 PM #7
Copying slected student pictures
I like the csv and loop idea. Here is a quick batch script in biterscripting ( http://www.biterscripting.com) .


# Script CopyPics.txt
cd "C:/StudentPictures"
var str list ; cat "MyStudents.csv" > $list
var str student ; lex "1" $list > $student
while ($student <> "")
do
system copy ($student+".jpg") "C:/CopyFolder"
lex "1" $list > $student
done
Reply

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.
Thread Tools



Facebook Facebook Twitter Twitter TechGuy.tv TechGuy.tv Mobile TSG Mobile
You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 10:23 AM.
Copyright © 1996 - 2011 TechGuy, Inc. All rights reserved.

Powered by Cermak Technologies, Inc.