Guest Darksoul71 Posted November 10, 2005 Share Posted November 10, 2005 Hi all, I´ve coded a small set of UDF´s dealing with filename / filepath processing. Here straight from the readme: <snip> * Functions included and what the do: Func _FileExtractPath ($FileName) This function extracts the file path without trailing "\" for a filename with path. Example: _FileExtractPath("C:\MyPath\MyFile.TXT") returns "C:\MyPath" * Func _FileExtractFilename ($FileName) This function extracts the file name for a filename with path. Example: _FileExtractFilename("C:\MyPath\MyFile.TXT") returns "MyFile.TXT" * Func _FileGetExt ($FileName) This function returns the extension for a filename with path without "." Example: Func _FileGetExt ("C:\MyPath\MyFile.TXT") returns "TXT" * Func _FileChangeExt ($FileName, $Extension) This function changes the extension for a filename with path. Example: Func _FileChangeExt ("C:\MyPath\MyFile.TXT", "doc") returns "C:\MyPath\MyFile.doc" *Func _FileStripExt ($FileName) This function strips the extension for a filename with path. Example: Func _FileStripExt ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile" Func _FileIncrementFileName ($FileName) This function generates a unique filename for a filename with path if the file exists. Example: Func _FileIncrementFileName ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile.TXT" when "C:\MyPath\MyFile.TXT" does not exist "C:\MyPath\MyFile (1).TXT" when "C:\MyPath\MyFile.TXT" does exist "C:\MyPath\MyFile (2).TXT" when "C:\MyPath\MyFile (1).TXT" does exist "C:\MyPath\MyFile (3).TXT" when "C:\MyPath\MyFile (2).TXT" does exist and so on. <snip> Have fun, D$Filename_UDF.zip Link to comment Share on other sites More sharing options...
Valik Posted November 10, 2005 Share Posted November 10, 2005 Most of these functions can be achieved by using _PathMake(), _PathFull(), or _PathSplit() in the standard AutoIt library of functions. At most, these functions could wrap the standard functions since yours do very little error checking and appear to be making some assumptions about the structure of a path. Link to comment Share on other sites More sharing options...
Guest Darksoul71 Posted November 10, 2005 Share Posted November 10, 2005 Most of these functions can be achieved by using _PathMake(), _PathFull(), or _PathSplit() in the standard AutoIt library of functions. At most, these functions could wrap the standard functions since yours do very little error checking and appear to be making some assumptions about the structure of a path.Hi Valik,1) Yeah, those functions do very little error checking as they were a quick hack. Never experienced any problems.2) Yup, I´m making assumptions on the structure of the path...but...isn´t that what a path always is ? Structured ? Structure of the path mainly defined by the OS. OK, my functions would fail for UNCs but forstandard Win path structure they work.3) I´ve never seen the functions you named. Are they standard of the current stable version ? If you call them standard, I would expect so.4) I don´t force any1 to use my messy lines of code -D$ Link to comment Share on other sites More sharing options...
Valik Posted November 10, 2005 Share Posted November 10, 2005 The functions are probably in the beta-only although the code for them should run under stable as well. The functions I mentioned support UNC paths and Unix style paths (Use / instead of \). They are well tested and although awkward to use, lend themselves well to being wrapped in other functions which does only a sub-set of what the full function does. Link to comment Share on other sites More sharing options...
Gene Posted November 11, 2005 Share Posted November 11, 2005 Most of these functions can be achieved by using _PathMake(), _PathFull(), or _PathSplit() in the standard AutoIt library of functions. At most, these functions could wrap the standard functions since yours do very little error checking and appear to be making some assumptions about the structure of a path.Hi Valik,I don't know which install put them there, but the UDFs you mentioned are in the Include folder hanging off the stable version. I have both the stable and beta 87 versions installed. There is no include folder associated with the beta folder. [font="Verdana"]Thanks for the response.Gene[/font]Yes, I know the punctuation is not right... Link to comment Share on other sites More sharing options...
Valik Posted November 11, 2005 Share Posted November 11, 2005 They were added on April 24, 2005 which correlates to version 3.1.1.13 so that have been in the beta since virtually the beginning. However, assuming the functions were left unaltered from my original implementation, they are probably 3.1.1 compliant as I wrote them a very long time ago. They have at least a year of use (by me) and likely more. Link to comment Share on other sites More sharing options...
Guest Darksoul71 Posted November 11, 2005 Share Posted November 11, 2005 Based on the suggestion of Valik I´ve modified my code and used the _PathSplit function from the beta to get the same functionality. Thus this version of "filename.au3" is depending on the UDF "File.au3" from the beta version of AutoIt. I´ve also added two new functions ("_DrivePercentFree" & "_IsSearchedType") which I need for another project. BTW: If anyone would like to include those functions into the standard _UDF package, I would be willing to do further documentation. Is there some "committee" deciding which UDF are good enough for being incorporated into the _UDF package ? Again from the readme: <snip> Functions included and what the do: *Func _FileExtractPath ($FileName) This function extracts the file path with trailing "\" for a filename with path. Example: _FileExtractPath("C:\MyPath\MyFile.TXT") returns "C:\MyPath\" * Func _FileExtractFilename ($FileName) This function extracts the file name for a filename with path. Example: _FileExtractFilename("C:\MyPath\MyFile.TXT") returns "MyFile.TXT" * Func _FileGetExt ($FileName) This function returns the extension for a filename with path with "." Example: _FileGetExt ("C:\MyPath\MyFile.TXT") returns ".TXT" * Func _FileChangeExt ($FileName, $Extension) This function changes the extension for a filename with path. Example: _FileChangeExt ("C:\MyPath\MyFile.TXT", "doc") returns "C:\MyPath\MyFile.doc" * Func _FileStripExt ($FileName) This function strips the extension for a filename with path. Example: _FileStripExt ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile" * Func _FileIncrementFileName ($FileName) This function generates a unique filename for a filename with path if the file exists. Example: _FileIncrementFileName ("C:\MyPath\MyFile.TXT") returns "C:\MyPath\MyFile.TXT" when "C:\MyPath\MyFile.TXT" does not exist "C:\MyPath\MyFile (1).TXT" when "C:\MyPath\MyFile.TXT" does exist "C:\MyPath\MyFile (2).TXT" when "C:\MyPath\MyFile (1).TXT" does exist "C:\MyPath\MyFile (3).TXT" when "C:\MyPath\MyFile (2).TXT" does exist and so on. I´ve provided a little sample script called "MoveFileUnique.au3" as example for what you can use this function. * Func _DrivePercentFree ($FullPath) This function return the available diskspace on a drive in % Example: _DrivePercentFree ("C:\") would return 50 if your HD has a size of 8 GB and 4 GB are still free. * Func _IsSearchedType ($FullPath, $Types) This function return "1" it the filename in $FullPath matches one of the extension defined by $Types and returns "0" if it doesn´t match any of the defined extensions. $Types can be a single extension without any separator (e.g. $Types = "txt") or multiple extensions using one of the following separators "|,;:", e.g. $Types = "avi,mpg,mpeg" is similar to $Types = "avi|mpg|mpeg" or $Types = "avi:mpg:mpeg" The dot for the extension is optional and will be added if missing, e.g. both $Types = ".avi,.mpg" and $Types = "avi,mpg" are valid. Extensions are NOT casesensitive and will be converted to uppercase prior comparison. Example _IsSearchedType ("C:\This is a file.txt", "txt,doc,rtf") would return 1 as one of the specified extensions is txt. <snip> Have fun, D$FileFunctions.zip Link to comment Share on other sites More sharing options...
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