Generate Random and unique directory name

More
4 years 10 months ago - 4 years 10 months ago #18262 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.
Last edit: 4 years 10 months ago by bruce.gibbins.

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #18279 by Maria
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
The following user(s) said Thank You: bruce.gibbins

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago #18281 by bruce.gibbins
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

Please Log in or Create an account to join the conversation.

More
4 years 10 months ago - 4 years 10 months ago #18293 by Peter.Jonson
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

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.

More
1 year 10 months ago #21194 by bruce.gibbins
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

Attachments:

Please Log in or Create an account to join the conversation.

More
1 year 10 months ago #21214 by Peter.Jonson
Sorry, I am very confused about your post.

Are saying that the function GetTempraryrFile does not work?

Peter Jonson
ETL Developer

Please Log in or Create an account to join the conversation.

Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Read more
Marketing
Set of techniques which have for object the commercial strategy and in particular the market study.
Google
Accept
Decline
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Functional
Tools used to give you more features when navigating on the website, this can include social sharing.