Computer Hope

Microsoft => Microsoft DOS => Topic started by: navin on September 09, 2008, 06:28:05 AM

Title: Creating batch file
Post by: navin on September 09, 2008, 06:28:05 AM
Hello

Hope you can help, I want create a batch file that can copy all jpeg, gif and mp3 files from a network drive I: on various machines and return the information on a text file.
Please post me what commands to use. Thanks
Title: Re: Creating batch file
Post by: fireballs on September 09, 2008, 06:34:34 AM
you cuold lookup
Code: [Select]
ftp /?
or use xcopy if all the computers are networked.

FB
Title: Re: Creating batch file
Post by: Dias de verano on September 09, 2008, 07:50:43 AM
why the poll?
Title: Re: Creating batch file
Post by: navin on September 09, 2008, 09:42:25 AM
Thanks, but let me be clear what exactly I want to do is I need to run query on user's home drive which should return me with information on all the jpeg, gif and mp3 files stored on their drives.

how would I go about creating a batch file that can to this task for me. All your help will be much appriciated. Thanks
Title: Re: Creating batch file
Post by: fireballs on September 09, 2008, 10:02:55 AM
that's better...

Code: [Select]
where /t /r c:\ *.mp3 *.gif *.jpeg
FB
Title: Re: Creating batch file
Post by: Dias de verano on September 09, 2008, 10:10:47 AM
that's better...

Code: [Select]
where /t /r c:\ *.mp3 *.gif *.jpeg
FB

fireballs, the where command is not part of a standard Windows installation.
Title: Re: Creating batch file
Post by: fireballs on September 09, 2008, 11:53:50 AM
it's part of the standard 'vista home premium'... but i appologise if it doesn't work. try
Code: [Select]
dir /s c:\ | find .mp3
dir /s c:\ | find .gif
dir /s c:\ | find .jpg

FB
Title: Re: Creating batch file
Post by: Dias de verano on September 09, 2008, 12:34:28 PM
it's part of the standard 'vista home premium'... but i appologise if it doesn't work.

OK. I'm still using XP.
Title: Re: Creating batch file
Post by: fireballs on September 09, 2008, 12:39:20 PM
i didn't know it was only on vista, thanks

FB
Title: Re: Creating batch file
Post by: dramklukkel on September 10, 2008, 03:55:55 AM
Hi FB

I think it needs an asterix. In XP it returns an error when that's not present. Unvalid parameter. Did not manage to output any results to a txtfile, because that produces the same error.
Code: [Select]
dir /s c:\ | find *.mp3
dir /s c:\ | find *.gif
dir /s c:\ | find *.jpg

This works for me though.
Code: [Select]
dir *.mp3 /s/w/b/o >> list.txt

grt,
Dramklukkel.
Title: Re: Creating batch file
Post by: fireballs on September 10, 2008, 05:24:21 AM
Hi FB

I think it needs an asterix. In XP it returns an error when that's not present. Unvalid parameter. Did not manage to output any results to a txtfile, because that produces the same error.
Code: [Select]
dir /s c:\ | find *.mp3
dir /s c:\ | find *.gif
dir /s c:\ | find *.jpg

This works for me though.
Code: [Select]
dir *.mp3 /s/w/b/o >> list.txt

grt,
Dramklukkel.

hmmm it seems this is another incompatability between vista and XP. i have to admit that i missed off quotation marks around the ".mp3" but if i use "*.mp3" it doesn't find anything  ???  >:(

also dir *.mp3 /s/w/b/o doesn't work for me.

FB
Title: Re: Creating batch file
Post by: navin on September 10, 2008, 10:07:22 AM
Guys Thanks very much for your help but I have tried all to no avail.

I am on windows 2000 and want the query to be returned on a text file
Title: Re: Creating batch file
Post by: Dias de verano on September 10, 2008, 10:08:04 AM
find needs quotes but you don't need find, because it may not do what you want.

dir | find ".mp3" will find any line in the output of dir which contains the 4 character string .mp3 so it would find this file which is not an mp3 file - horsecowcatdog.mp3.doc

You do need an asterisk for filespec wildcards as used by dir.

dir *.mp3 will find only files with the extension .mp3
Title: Re: Creating batch file
Post by: fireballs on September 10, 2008, 10:16:03 AM
to get the output in a text file use:
Code: [Select]
dir *.mp3>list.txt
dir *.jpg>>list.txt
dir *.gif>>list.txt

FB
Title: Re: Creating batch file
Post by: Dias de verano on September 10, 2008, 11:03:57 AM
Thanks, but let me be clear what exactly I want to do is I need to run query on user's home drive which should return me with information on all the jpeg, gif and mp3 files stored on their drives.

how would I go about creating a batch file that can to this task for me. All your help will be much appriciated. Thanks

Is this your school homework?
Title: Re: Creating batch file
Post by: fireballs on September 10, 2008, 04:51:18 PM

Is this your school homework?


using DOS? i don't think DOS has ever been taught in schools.

FB
Title: Re: Creating batch file
Post by: Dias de verano on September 11, 2008, 11:34:03 AM
i don't think DOS has ever been taught in schools.

On what do you base that statement?

A reply please.



Title: Re: Creating batch file
Post by: Jacob on September 11, 2008, 11:46:54 AM
i don't think DOS has ever been taught in schools.

On what do you base that statement?

A reply please.





I haven't been taught it.
May be different in America.
Title: Re: Creating batch file
Post by: Dias de verano on September 11, 2008, 11:53:36 AM
Schools in many countries all around the world use MS-DOS, Qbasic, batch language, Windows command prompt in their computer and IT courses. To say that "DOS" has never been taught in schools is a remarkably sweeping (and rather ignorant) statement.
Title: Re: Creating batch file
Post by: Jacob on September 11, 2008, 11:54:53 AM
Schools in many countries all around the world use MS-DOS, Qbasic, batch language, Windows command prompt in their computer and IT courses. To say that "DOS" has never been taught in schools is a remarkably sweeping (and rather ignorant) statement.


True, I was just adding that it is not in the English curriculum.
Title: Re: Creating batch file
Post by: Dias de verano on September 11, 2008, 12:00:57 PM
Quote from: Jacob
True, I was just adding that it is not in the English curriculum.

Well, they teach it in at least one secondary school in Bristol that I know about.
Title: Re: Creating batch file
Post by: Jacob on September 11, 2008, 12:06:41 PM
Quote from: Jacob
True, I was just adding that it is not in the English curriculum.

Well, they teach it at least one secondary school in Bristol that I know about.

Well obviously I am wrong.
I forgot schools can change their curriculum, and obviously if an IT technician or teacher feels teaching DOS would be beneficial then they can teach it, with the backing of the headteacher and or governing body.
Title: Re: Creating batch file
Post by: Dias de verano on September 11, 2008, 12:28:03 PM
You clearly haven't noticed the large number of DOS homework questions that are posted in this part of the forum.
Title: Re: Creating batch file
Post by: Jacob on September 11, 2008, 01:00:30 PM
Wrong, I have.
But I don't see why you are getting shirty with me, I didn't make the assumption in the first place.
Title: Re: Creating batch file
Post by: Dias de verano on September 11, 2008, 02:11:42 PM
Wrong, I have.
But I don't see why you are getting shirty with me, I didn't make the assumption in the first place.

I'm sorry, I didn't mean to sound shirty. Sorry if it came over that way. I posted in haste. Also you're right, it was our friend who hasn't answered who made the assumption.
Title: Re: Creating batch file
Post by: fireballs on September 12, 2008, 05:30:35 AM
yup i was wrong, sorry. I guess we both posted in haste.


FB
Title: Re: Creating batch file
Post by: Dias de verano on September 12, 2008, 10:07:52 AM
Still, there's always a silver lining - our post counts have gone up  :)
Title: Re: Creating batch file
Post by: navin on September 16, 2008, 05:07:12 AM
Thanks for your help, I have now managed to create the batch file BUT the main issue is I neet to connect to user's I drives, approximatelt 200 drives to obtain the information. so this is what the objective is.......Run batch file  to connect to I:\servername\username$ ......obtain list of jpeg on this drive .....copy on text file on my C:\drive.
I have around 200 different username$ to connect to on five different servernames.

Please assist as your previous input has been very helpful. Thanks to all.
Title: Re: Creating batch file
Post by: navin on September 17, 2008, 01:08:16 AM
Hi guys thanks for your help,

I really want to access user's homes drives to obtain the information, the objective is:
use batch file to connect to user's home drive: \\servername\username$
copy information on all jpeg files on a text file and return to me on my home drive.
There are approximately 200 users on five different servers.
All your help is appriciated. Thanks