Log in

View Full Version : create a windows batch file


jumpy
09-02-08, 10:47 AM
hey all, I need someone who knows how to write a windows batch file to return a list (in a simple .txt file) of a specific file extension (.dwg) in the current directory that the batch file is run from.

I used to have one of these but canot find or remember how to code it.

Can anyone help?

Digital_Trucker
09-02-08, 11:29 AM
dir *.dwg > textfilename.txt will give you a list of all the files with file extensions of .dwg, but it will also give some extraneous lines at the beginning and end and will list information other than just the file name

jumpy
09-02-08, 11:50 AM
hmm, thanks that's the stuff. Any ideas about including subdirectories of the folder that the .bat file is located in?

VipertheSniper
09-02-08, 11:51 AM
cmd /C dir /S *.dwg /A > list.txt

This will close the console after it's finished. And also give you the files located in subdirectories... depending on how much there are you'll maybe want to use the the switch /B with the dir command, then you'll only get the paths written to the text file

The command in the batch file would look like this...
cmd /C dir /S /B *.dwg /A > list.txt

Or easier dir /S /B *.dwg > list.txt

That'll close aswell after it has finished

jumpy
09-02-08, 12:00 PM
nevermind, I think I've found what I'm looking for thanks to your prompt :up:

DIR *.DWG /s /b > DWGlist.txt

EDIT:

ahah! there's more lol

jumpy
09-02-08, 12:36 PM
I never did learn how to use dos code properly

basic AutoLisp code, now that I can handle (well mostly).

Thanks again :up:

jumpy
09-03-08, 04:52 AM
All works according to plan until I try and use it on a network drive, on the console pops up for a split second and complains about UNC something or other.:cry:

Ah well.

VipertheSniper
09-03-08, 10:45 AM
Go to the folder you want to execute the *.bat from, then just paste the command of the batch file into the console. The console will stay open, and you can read the error message.