SUBSIM Radio Room Forums



SUBSIM: The Web's #1 resource for all submarine & naval simulations since 1997

Go Back   SUBSIM Radio Room Forums > General > General Topics
Forget password? Reset here

Reply
 
Thread Tools Display Modes
Old 09-02-08, 10:47 AM   #1
jumpy
Admiral
 
Join Date: May 2003
Location: Midlands, UK
Posts: 2,139
Downloads: 22
Uploads: 0
Default create a windows batch file

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?
__________________

when you’ve been so long in the desert, any water, no matter how brackish, looks like life


jumpy is offline   Reply With Quote
Old 09-02-08, 11:29 AM   #2
Digital_Trucker
Silent Hunter
 
Join Date: Jul 2007
Location: The Peach State
Posts: 4,171
Downloads: 141
Uploads: 10
Default

Code:
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
__________________

RSM-GIEP-Killflags-LV Tribute-Playable Elco __Peace be with you, Dave.

Digital_Trucker is offline   Reply With Quote
Old 09-02-08, 11:50 AM   #3
jumpy
Admiral
 
Join Date: May 2003
Location: Midlands, UK
Posts: 2,139
Downloads: 22
Uploads: 0
Default

hmm, thanks that's the stuff. Any ideas about including subdirectories of the folder that the .bat file is located in?
__________________

when you’ve been so long in the desert, any water, no matter how brackish, looks like life


jumpy is offline   Reply With Quote
Old 09-02-08, 11:51 AM   #4
VipertheSniper
Ace of the Deep
 
Join Date: Sep 2002
Location: Austria
Posts: 1,070
Downloads: 0
Uploads: 0
Default

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

Last edited by VipertheSniper; 09-02-08 at 12:02 PM.
VipertheSniper is offline   Reply With Quote
Old 09-02-08, 12:00 PM   #5
jumpy
Admiral
 
Join Date: May 2003
Location: Midlands, UK
Posts: 2,139
Downloads: 22
Uploads: 0
Default

nevermind, I think I've found what I'm looking for thanks to your prompt

Code:
DIR *.DWG /s /b > DWGlist.txt
EDIT:

ahah! there's more lol
__________________

when you’ve been so long in the desert, any water, no matter how brackish, looks like life


jumpy is offline   Reply With Quote
Old 09-02-08, 12:36 PM   #6
jumpy
Admiral
 
Join Date: May 2003
Location: Midlands, UK
Posts: 2,139
Downloads: 22
Uploads: 0
Default

I never did learn how to use dos code properly

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

Thanks again
__________________

when you’ve been so long in the desert, any water, no matter how brackish, looks like life


jumpy is offline   Reply With Quote
Old 09-03-08, 04:52 AM   #7
jumpy
Admiral
 
Join Date: May 2003
Location: Midlands, UK
Posts: 2,139
Downloads: 22
Uploads: 0
Default

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.

Ah well.
__________________

when you’ve been so long in the desert, any water, no matter how brackish, looks like life


jumpy is offline   Reply With Quote
Old 09-03-08, 10:45 AM   #8
VipertheSniper
Ace of the Deep
 
Join Date: Sep 2002
Location: Austria
Posts: 1,070
Downloads: 0
Uploads: 0
Default

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.
VipertheSniper is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 05:33 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 1995- 2025 Subsim®
"Subsim" is a registered trademark, all rights reserved.