Reading folder name

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
pyniu
Posts: 1
Joined: 15 Nov 2011 15:09

Reading folder name

#1 Post by pyniu » 15 Nov 2011 15:16

Hi
i'm beginner and i need help with reading previously created directory name, and open it.

Firstly i'll present you what i exactly want in steps.

1. Run test.exe
After running test.exe, some operations has been made and directory with random name has been created.

2. Open folder created in step1 and extract .cab file


Like i previously wrote i'm beginner and don't know how to open directory which was created few steps earlier.

someone will help me?

phillid
Posts: 109
Joined: 03 Apr 2010 20:27
Location: Wellington, New Zealand
Contact:

Re: Reading folder name

#2 Post by phillid » 29 Dec 2011 19:27

The batch script language is more or less make for doing things like these.

To run a program, we simply do what's called 'call' it from the command line like this:

Code: Select all

test.exe


Assuming the batch file containing this code is in the same directory as 'test.exe' or 'test.exe' is in a directory specified in the %PATH% evironment variable.

To change the directory that the batch file is in ("Current Directory" or "Working Directory"), we use the CD command

Code: Select all

cd [folder]

where folder is the name to go into, or change to, for example, I could use:

Code: Select all

cd "C:\Program Files\Windows Media Player"

to switch to the path C:\Program Files\Windows Media Player

[quote=pyniu]...directory with random name has been created.[/quote]
We can't change to a directory without knowing its name, unless the name always follows a pattern, like '123' followed by 4 letters, or some other pattern

Hope this helps :)

--Phillid

Post Reply