Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: Generate Random and unique directory name

Generate Random and unique directory name 1 year 2 weeks ago #18262

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.

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

Generate Random and unique directory name 1 year 2 weeks ago #18279

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.

Generate Random and unique directory name 1 year 2 weeks ago #18281

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.

Generate Random and unique directory name 1 year 1 week ago #18293

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
Support Analist
The following user(s) said Thank You: bruce.gibbins

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

  • Page:
  • 1

We have 269 guests and no members online