Sign in to follow this  
Followers 0
RogueX2

Get the name of a dir

7 posts in this topic

The name of a particular directory/folder changes. The only part of the name that stays consistent is the last 9 characters. Can I pull the name of the dir after it is copied using dirCopy? Or do I have to work with _filelisttoarray?

Share this post


Link to post
Share on other sites



Hi!!

Maybe you can check the AutoIT help for FileFindFirstFile example, and use the FileChangeDir to change the working dir.

Hope this help.

Share this post


Link to post
Share on other sites

Roguex2,

If you can detect the name change then you can likely get the dir name.

There is not enough info/code here to provide an adequate response.

kylomas


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

Roguex2,

If you can detect the name change then you can likely get the dir name.

There is not enough info/code here to provide an adequate response.

kylomas

Basically I am copying a folder that is the "only folder in a particular directory" over to a desktop using DirCopy("\\location\location*.*"). I would then need to open the folder that has been copied to the destkop. However since I don't know the name I can't access it.

I guess I could use _filelisttoarray and the name would be in array [1]. How do I pass that value to string?

Thanks

Share this post


Link to post
Share on other sites

You can use wildcards

FileChangeDir(@DesktopDir)

$search = FileFindFirstFile("*.") <=== search for all the directories

or u can use the last 9 characters

$search = FileFindFirstFile("*123456789.") <=== this will match every dir with the characters "123456789" at the end.

then use the

$file = FileFindNextFile($search) to get the name.

Share this post


Link to post
Share on other sites

You can use wildcards

FileChangeDir(@DesktopDir)

$search = FileFindFirstFile("*.") <=== search for all the directories

or u can use the last 9 characters

$search = FileFindFirstFile("*123456789.") <=== this will match every dir with the characters "123456789" at the end.

then use the

$file = FileFindNextFile($search) to get the name.

Thanks...will when I get to work this morning.

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You can do a search for the folder using wildcards (*) using FileFindFirstFile (also works on directories).

$search = FileFindFirstFile("*LastNineChars")
$dir = FileFindNextFile($search)

It is necessary to add error checking in the example above.

Edited by Manadar

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0