DTNGUYEN Posted April 12, 2010 Posted April 12, 2010 (edited) I would like to get parent folder path base on @ScriptDir. Please kind to help how to do it. Eg, @ScriptDir returns "C:\AutoIt\Script I would like to get "C:\AutoIt" in this case. Edited April 12, 2010 by DTNGUYEN
ChrisL Posted April 12, 2010 Posted April 12, 2010 $ParentDir = StringLeft(@scriptDir,StringInStr(@scriptDir,"\",0,-1)-1) Msgbox(0,"", $ParentDir ) [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
KaFu Posted April 12, 2010 Posted April 12, 2010 $dir = @ScriptDir $dir_parent = StringLeft($dir,StringInStr($dir,"\",0,-1)-1) MsgBox(0,"",$dir_parent) OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16)
Yashied Posted April 12, 2010 Posted April 12, 2010 (edited) StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '') Edited April 12, 2010 by Yashied Synapsee 1 My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More...
DTNGUYEN Posted April 12, 2010 Author Posted April 12, 2010 Thanks for help. However, i just find out another way to get by using _PathFull #incllude<file.au3> @LIB_DIR = _PathFull(@ScriptDir & "..\..\") & "LIB\"
Cyri Posted April 16, 2010 Posted April 16, 2010 StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '') Slightly off topic...I like this solution, but how would I modify it to only show the parent folder name and trim the left side of the path off. For example: Have this: $sPath = "C:\test1\test2\test3\test4\test.xml" Need this: $sParent = "test4" Basically just the parent folder name and not the full path to the parent folder.
sahsanu Posted April 17, 2010 Posted April 17, 2010 Have this: $sPath = "C:\test1\test2\test3\test4\test.xml" Need this: $sParent = "test4" Basically just the parent folder name and not the full path to the parent folder. Something like this? $test=StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '') $test=StringRegExpReplace($test, '.*\\', '') Synapsee 1
Cyri Posted April 17, 2010 Posted April 17, 2010 Something like this? $test=StringRegExpReplace(@ScriptDir, '\\[^\\]*$', '') $test=StringRegExpReplace($test, '.*\\', '') Thanks that should do the trick.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now