Generate Random and unique directory name

  • Posts: 490
  • Karma: 2
  • Thank you received: 48

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.
3 years 10 months ago #18262

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

  • Posts: 159
  • Thank you received: 17

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

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

  • Posts: 490
  • Karma: 2
  • Thank you received: 48

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
3 years 10 months ago #18281

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

  • Posts: 1225
  • Karma: 3
  • Thank you received: 160

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
Peter Jonson
ETL Developer
The following user(s) said Thank You: bruce.gibbins
3 years 10 months ago #18293

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

  • Posts: 490
  • Karma: 2
  • Thank you received: 48

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

10 months 2 weeks ago #21194
Attachments:

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

  • Posts: 1225
  • Karma: 3
  • Thank you received: 160

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?
Peter Jonson
ETL Developer
10 months 2 weeks ago #21214

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

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies