Mourning the loss of our friend, WhitPhil.
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
Search
 
DOS/PDA/Other
Tag Cloud
access audio black screen blue screen boot bsod connection crash dell desktop driver drivers dvd email error excel firefox hard drive hardware hijackthis internet keyboard laptop malware monitor motherboard network networking outlook problem processor recovery registry cleaner router safe mode slow sound spyware tdlwsp.dll trojan vba video virus vista vundo windows windows 7 windows vista windows xp wireless
Search
Search for:
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
Batch file to copy files by filename

Tip: Click here to scan for System Errors and Optimize PC performance
[ Sponsored Link ]

 
Thread Tools
yoda_pooh's Avatar
Junior Member with 1 posts.
 
Join Date: Oct 2009
Experience: Beginner
09-Oct-2009, 02: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, 04: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
Distinguished Member with 14,988 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
09-Oct-2009, 08: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, 03: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
Distinguished Member with 14,988 posts.
 
Join Date: Apr 2003
Location: 1265 Lombardi Ave
Experience: IIAHYAYCESA,YAADA!
10-Oct-2009, 09: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, 01: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 3 posts.
 
Join Date: Jun 2009
02-Nov-2009, 11:49 AM #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 Bookmark and Share

Smart Search

Find your solution!



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


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -5. The time now is 11:50 AM.
Copyright © 1996 - 2009 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.
Powered by Cermak Technologies, Inc.