Any script kiddies? Batching pro's?

0 Members and 1 Guest are viewing this topic. Read 2029 times.

JoshK

Any script kiddies? Batching pro's?
« on: 27 Jul 2007, 11:47 pm »
I am looking to update a music database and would love to write a batch file that pulled the name of directories and sub-dir's. Anyone know how to reference the name of dir's or subdir's in batch? Or even better, know where to look up the help files/code logic online?

I am just going to write a batch for what I want to do as it'll be quicker/simpler that way.  I am just seriously rusty on dos. 

Papajin

  • Jr. Member
  • Posts: 276
Re: Any script kiddies? Batching pro's?
« Reply #1 on: 28 Jul 2007, 12:24 am »
I am looking to update a music database and would love to write a batch file that pulled the name of directories and sub-dir's. Anyone know how to reference the name of dir's or subdir's in batch? Or even better, know where to look up the help files/code logic online?

I am just going to write a batch for what I want to do as it'll be quicker/simpler that way.  I am just seriously rusty on dos. 

Can you give more insight as to what sort of directory structure you're talking about, and what exactly you're trying to do with it?  Unfortunately the DOS/Windows Batch/CMD facilities are rather limited as compared to the unix scripts, so it can sometimes be difficult to get anything useful out of them, but if you're doing something relatively simple, it can be possible.  Anything more complex you might want to try perl or another scripting language instead.

PS: You may want to rethink you use of the term "script kiddie" in your original post.  It's generally considered a negative term for young kids that get their jollies using pre-written scripts to attempt to hack into websites and other online sites. :)

BradJudy

Re: Any script kiddies? Batching pro's?
« Reply #2 on: 28 Jul 2007, 01:57 am »
Yeah, more info would be good.  Do you just want a list of all of the directories?  Something like:

dir /a:d /s /h

will just give you a list of all of the directories, but with their full path.  Breaking that down would require using a parsing tool. 

richidoo

Re: Any script kiddies? Batching pro's?
« Reply #3 on: 28 Jul 2007, 02:29 am »

Bob Reynolds

  • Full Member
  • Posts: 526
Re: Any script kiddies? Batching pro's?
« Reply #4 on: 28 Jul 2007, 03:47 am »
The Windows command line interpreter is extremely limited (any unix guy would say brain damaged). MS has something called PowerShell now, but doing anything non-trivial requires a scripting language. Either jscript or vbscript can utilize the FileSystemObject which provides reasonable functionality for doing stuff with the file system.

Go to the MS scripting site for downloads and info.

JohnR

Re: Any script kiddies? Batching pro's?
« Reply #5 on: 28 Jul 2007, 04:18 am »
You could always install Cygwin and write a shell script (with sed, awk, grep etc)

mgalusha

Re: Any script kiddies? Batching pro's?
« Reply #6 on: 28 Jul 2007, 12:29 pm »
There are also ports of bash to windows if you want a UNIX type shell. http://www.steve.org.uk/Software/bash/

Not sure what you're trying to do but adding the /B (bare) switch to Brad's command line will give you just the directory info without all the data about those directories.

You will likely want to redirect the output to a file.

C:\>dir /s /ad /b \development > dirlist.txt

This produces the following output format:

C:\development\SBFirmwareSelector
C:\development\SBFirmwareSelector\bin
C:\development\SBFirmwareSelector\obj
C:\development\SBFirmwareSelector\obj\Debug
C:\development\SBFirmwareSelector\obj\Debug\temp
C:\development\SBFirmwareSelector\obj\Debug\TempPE


JoshK

Re: Any script kiddies? Batching pro's?
« Reply #7 on: 28 Jul 2007, 10:27 pm »
Thanks guys.  This gave me enough info to start from.

I guess what I was looking to try was to cross my music server directory structure to see which albs are installed there versus my music collector database. Each have a couple hundred or more entries but there are unique ones on both sides and I was trying to update the musicollector db to get it up to date more easily.  I've acquired over a hundred CD's in the last few months and didn't want to go through which I haven't added manually.

I can export a list from MC and I was trying to get a list from my windows dir structure since they are all named artist\album anyway.  Then I know what to do from there.  What Mike showed will work for me, even if it is a little rougher than I really want.

JoshK

Re: Any script kiddies? Batching pro's?
« Reply #8 on: 28 Jul 2007, 10:37 pm »
hmm that didn't work

I did

M:\> dir /s /ad /b \development > dirlist.txt

it created the dirlist.txt in M:\ but then said "File Not Found"  tried it again, said thing.

What does the \development do?

JoshK

Re: Any script kiddies? Batching pro's?
« Reply #9 on: 28 Jul 2007, 10:47 pm »
I took the > dirlist.txt out to see what it did on screen, gave me the file not found, so I lost the \development and it spit the output to the screen ok, so I added back the redirect to output and got what I wanted.  So I am not sure what the \development was for. 

BradJudy

Re: Any script kiddies? Batching pro's?
« Reply #10 on: 29 Jul 2007, 01:55 am »
There are also ports of bash to windows if you want a UNIX type shell. http://www.steve.org.uk/Software/bash/

Not sure what you're trying to do but adding the /B (bare) switch to Brad's command line will give you just the directory info without all the data about those directories.

You will likely want to redirect the output to a file.

C:\>dir /s /ad /b \development > dirlist.txt


Ooops, mine was suppose to be a /b, not a /h. 

BTW Mike, this is a set of Unix CLI tools for Windows, I use them regularly at work: http://unxutils.sourceforge.net/

It's not a bash shell, but for most of what I do, I want grep/awk/sort/etc rather than the shell itself. 

mgalusha

Re: Any script kiddies? Batching pro's?
« Reply #11 on: 29 Jul 2007, 12:20 pm »
What does the \development do?

The \development was the path I had it check. As you discovered it's optional. If not supplied it just starts from where you execute the command. You could execute it from your c: to point to M: using that.

example: C:\> dir /s /ad /b m:\ > dirlist.txt

You can put a path in for the output file as well.

M:\> dir /s /ad /b > c:\somefolder\dirlist.txt

mgalusha

Re: Any script kiddies? Batching pro's?
« Reply #12 on: 29 Jul 2007, 12:21 pm »
BTW Mike, this is a set of Unix CLI tools for Windows, I use them regularly at work: http://unxutils.sourceforge.net/

It's not a bash shell, but for most of what I do, I want grep/awk/sort/etc rather than the shell itself. 

Thanks Brad, I actually have those installed as well. Having grep on a Winbox is very helpful. :)

Mike