Jump to content
Sign in to follow this  
Chimaera

Getting a folder address but it needs wildcard?

Recommended Posts

Chimaera

Im trying to backup a folder that belongs to a wamp server

C:\wamp\bin\mysql\mysql5.6.17\data

but the problem is this bit

mysql5.6.17

its a shame i cant do this

mysql*\data

 for every version of mysql the numbers change so i cant get a definitive address for the backup

Ive searched and rechecked all my saved stuff but im surprised that i cant find anything suitable

is there a simple way to get the destination?

Share this post


Link to post
Share on other sites
pcjunki

what's your code?

couldn't you use dircopy?

DirCopy("c:\wamp\bin\mysql", "c:\backup")

 

 

Share this post


Link to post
Share on other sites
iamtheky

you could let Dir fill out the wildcard, then use the return, of course this relies on there being no risk of multiple matches.

 

#include <Constants.au3>

$sPath = "C:\Program Files (x86)\"
$sWildDir = "AutoIt*"
$sFile = "Au3Info.exe"

Local $iPID = Run(@ComSpec & ' /c dir /B "' &  $sPath & $sWildDir & '"', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then
            ExitLoop
        EndIf
    WEnd

$sFullSrc = $sPath & stringstripws($sOutput , 2) & "\" & $sFile

filecopy($sFullSrc , @ScriptDir & "\backup_" & $sFile)

 

Edited by boththose

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
Chimaera

what's your code?

couldn't you use dircopy?

DirCopy("c:\wamp\bin\mysql", "c:\backup")

No because i dont want the lower directories only the data one

Why not do a _FileListToArray, and then hit on any directories matching your criteria?

I had a look with FileListToArrayRec but couldnt isolate it down to just the one folder i need

So i ended up like this from Boththose suggestion

#include <Constants.au3>

$sPath = "c:\wamp\bin\mysql\mysql*"

Local $iPID = Run(@ComSpec & ' /c dir /B "' &  $sPath & '"', @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD)
    Local $sOutput = ""
    While 1
        $sOutput &= StdoutRead($iPID)
        If @error Then
            ExitLoop
        EndIf
    WEnd

$sOutput = 'c:\wamp\bin\mysql\' & StringStripWS( $sOutput, 2) & '\data'

ConsoleWrite(  $sOutput & @CRLF)

Which appears to work for me and gives this output

c:\wamp\bin\mysql\mysql5.6.17\data

which is the dir im after.

 

Many thanks for the help

Edited by Chimaera

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  

×