- Posts: 539
- Thank you received: 59
Generate Random and unique directory name
- bruce.gibbins
- Topic Author
- Offline
- Platinum Member
-
Less More
4 years 10 months ago - 4 years 10 months ago #18262 by bruce.gibbins
Generate Random and unique directory name was created by bruce.gibbins
Hi. Not sure if anyone else will see value in this but I come across it because of the variety of inbound files and the different methods in which we have to consume them.
Sometimes I would find it handy to create a temporary directory with a unique name to hold a set of files. That then gets blown away at completion.
I could use GUID or come up with my own using various random functions etc. But it would be handy to encapsulate the name generator and folder exist check and folder create all in a single function or file action that takes maybe a root path as the home for the temp folder. From there it generates say a set of random characters that then forms a foldername. This is. Checked for existence and if exists the process repeats till it gets a non existent folder at which point it creates it.
Sometimes I would find it handy to create a temporary directory with a unique name to hold a set of files. That then gets blown away at completion.
I could use GUID or come up with my own using various random functions etc. But it would be handy to encapsulate the name generator and folder exist check and folder create all in a single function or file action that takes maybe a root path as the home for the temp folder. From there it generates say a set of random characters that then forms a foldername. This is. Checked for existence and if exists the process repeats till it gets a non existent folder at which point it creates it.
Last edit: 4 years 10 months ago by bruce.gibbins.
Please Log in or Create an account to join the conversation.
4 years 10 months ago #18279 by Maria
Replied by Maria on topic Generate Random and unique directory name
I think there is a standard windows function for creating temporary folders/files
(We use it internally)
I will add it the list of things to do
(We use it internally)
I will add it the list of things to do
The following user(s) said Thank You: bruce.gibbins
Please Log in or Create an account to join the conversation.
- bruce.gibbins
- Topic Author
- Offline
- Platinum Member
-
Less More
- Posts: 539
- Thank you received: 59
4 years 10 months ago #18281 by bruce.gibbins
Replied by bruce.gibbins on topic Generate Random and unique directory name
I was also thinking that it could be incorporated into a directory connection such that you provide a checkbox indicating that it is a temporary folder and the path with be generated using a random name.
Not sure how to best cleanup the folder afterwards but maybe a standalone transformation that uses it can delete it when the writer completes. This may need to be driven by a checkbox flag again. Plus maybe if it is used in a package then it is managed by file operations in the package.
Cheers
Not sure how to best cleanup the folder afterwards but maybe a standalone transformation that uses it can delete it when the writer completes. This may need to be driven by a checkbox flag again. Plus maybe if it is used in a package then it is managed by file operations in the package.
Cheers
Please Log in or Create an account to join the conversation.
- Peter.Jonson
-
- Offline
- Platinum Member
-
4 years 10 months ago - 4 years 10 months ago #18293 by Peter.Jonson
Peter Jonson
ETL Developer
Replied by Peter.Jonson on topic Generate Random and unique directory name
Hi Bruce
We have added a number of functions to scripting language which helps to work with Temporary Folders/Files
Here is an example
begin
SetVariable('<Directory>',GetTemporaryDirectory('c:\tmp'));
Result:=True;
end;
Here is the full list of functions
GetWindowsTemporaryDirectory
The GetWindowsTemporaryDirectory function returns windows temporary path.
GetTemporaryFile(Extension)
The GetTemporaryFile function returns a temporary file path. The file is located in windows temporary directory
GetTemporaryFileInDirectory(Directory,Extension)
The GetTemporaryFileInDirectory function returns temporary file path. The file is located in the directory
GetTemporaryDirectory(Directory)
The GetTemporaryDirectory function returns a temporary directory name in a specified directory
The rest of the changes is
6.3.2.12
+ Added: GetWindowsTemporaryDirectory,GetTemporaryFile,GetTemporaryFileInDirectory,GetTemporaryDirectory transformation language functions
+ Added: Get File Content Dynamic transformation function
+ Improved: Third party components update
+ Improved: Pivot and unpivot performance
We have added a number of functions to scripting language which helps to work with Temporary Folders/Files
Here is an example
begin
SetVariable('<Directory>',GetTemporaryDirectory('c:\tmp'));
Result:=True;
end;
Here is the full list of functions
GetWindowsTemporaryDirectory
The GetWindowsTemporaryDirectory function returns windows temporary path.
GetTemporaryFile(Extension)
The GetTemporaryFile function returns a temporary file path. The file is located in windows temporary directory
GetTemporaryFileInDirectory(Directory,Extension)
The GetTemporaryFileInDirectory function returns temporary file path. The file is located in the directory
GetTemporaryDirectory(Directory)
The GetTemporaryDirectory function returns a temporary directory name in a specified directory
The rest of the changes is
6.3.2.12
+ Added: GetWindowsTemporaryDirectory,GetTemporaryFile,GetTemporaryFileInDirectory,GetTemporaryDirectory transformation language functions
+ Added: Get File Content Dynamic transformation function
+ Improved: Third party components update
+ Improved: Pivot and unpivot performance
Peter Jonson
ETL Developer
Last edit: 4 years 10 months ago by Peter.Jonson.
The following user(s) said Thank You: bruce.gibbins
Please Log in or Create an account to join the conversation.
- bruce.gibbins
- Topic Author
- Offline
- Platinum Member
-
Less More
- Posts: 539
- Thank you received: 59
1 year 10 months ago #21194 by bruce.gibbins
Replied by bruce.gibbins on topic Generate Random and unique directory name
Hi. I was wondering if others would see the value in being able to access these functions from within some of the File Operation Target operations in such a way that the temporary filename and path are used in say a Create List File Operation and then the full Filename is returned back as a Variable so it can be used in a Loop etc.
The screen shot explains better.
Thanks Again for a great product.
bruce
The screen shot explains better.
Thanks Again for a great product.
bruce
Please Log in or Create an account to join the conversation.
- Peter.Jonson
-
- Offline
- Platinum Member
-
1 year 10 months ago #21214 by Peter.Jonson
Peter Jonson
ETL Developer
Replied by Peter.Jonson on topic Generate Random and unique directory name
Sorry, I am very confused about your post.
Are saying that the function GetTempraryrFile does not work?
Are saying that the function GetTempraryrFile does not work?
Peter Jonson
ETL Developer
Please Log in or Create an account to join the conversation.