Topic
  • 3 replies
  • Latest Post - ‏2013-12-17T11:05:38Z by VolkerFriedrich
Robertc65
Robertc65
15 Posts

Pinned topic Appending Date / Time to filename

‏2013-12-11T20:24:39Z |

I am having lots of trouble figuring out how C:D renames files. In this example below I'm trying append the date and time to the original filename without success.

Variables :  &Date=%SUBDATE and &Time=%SUBTIME

Source Filename : P.NYCITY.DLYLETR.txt

 Source : D\:Data\*

 Target :  \\file_serv01\Letters\P.NYCITY.DLYLETR.D&Date.&Time..txt

Resulting Filename in target folder : P.NYCITY.DLYLETR.D1131211144816.txtP.NYCITY.DLYLETR.txt

It appears to pre-pend the filename and dateTime to the filename.

What am I doing wrong. This is not the only time I got an unexpected result in the filename. I have the C:D documentation, but it does not do a very good job of explaining the issue of filenames. Do you know if there is a source of info on this somewhere that is better than the actual manual?

Thanks

Rob

 

 

 

 

 

 

 

  • VolkerFriedrich
    VolkerFriedrich
    156 Posts

    Re: Appending Date / Time to filename

    ‏2013-12-13T14:26:01Z  

    You are doing a wildcard copy here, which makes is somehow special. In this case C:D appends the matching source filename to the specified target, which explains your resulting filename.

    Removing the wildcard and hard-coding the source instead would probably give you the desired result.
     Source : D\:Data\P.NYCITY.DLYLETR.txt

    Note that your step here with a wildcard source but a hard-coded target leaves a potential risk of your target file being overwritten, like when the wildcard matches more than one source file.

    If you need wildcards and flexibility, you want to have a look at Connect:Direct File Agent. It can monitor directories and submit processes using a variety of variables, especially around filenames and date/time.

     

  • Robertc65
    Robertc65
    15 Posts

    Re: Appending Date / Time to filename

    ‏2013-12-13T19:31:57Z  

    You are doing a wildcard copy here, which makes is somehow special. In this case C:D appends the matching source filename to the specified target, which explains your resulting filename.

    Removing the wildcard and hard-coding the source instead would probably give you the desired result.
     Source : D\:Data\P.NYCITY.DLYLETR.txt

    Note that your step here with a wildcard source but a hard-coded target leaves a potential risk of your target file being overwritten, like when the wildcard matches more than one source file.

    If you need wildcards and flexibility, you want to have a look at Connect:Direct File Agent. It can monitor directories and submit processes using a variety of variables, especially around filenames and date/time.

     

    Thanks for the response Volker. I use the Fileagent for other jobs it's just that this job is triggered based on time so I did not see the need for the file agent. The way this is engineered, only one file at a time will ever be present in the source folder, but we are never sure what the name will be which is why I used a wildcard. Are you aware of any documentation that explains in detail the rules for how files are named in C:D. I have seen examples and have been able to figure out some of the syntax with trial and error, but I clear explaination would be very helpful. For example I sometimes see a period at the end of a variable. Sometimes I see two periods. Sometimes variables are quoted, sometimes they are not. If I knew the actual syntax rules, it would really be helpful. I have never actually found any examples of windows to windows copy processes in the System Guide or Language Reference.

     

    Thanks

    Rob

     

     

  • VolkerFriedrich
    VolkerFriedrich
    156 Posts

    Re: Appending Date / Time to filename

    ‏2013-12-17T11:05:38Z  
    • Robertc65
    • ‏2013-12-13T19:31:57Z

    Thanks for the response Volker. I use the Fileagent for other jobs it's just that this job is triggered based on time so I did not see the need for the file agent. The way this is engineered, only one file at a time will ever be present in the source folder, but we are never sure what the name will be which is why I used a wildcard. Are you aware of any documentation that explains in detail the rules for how files are named in C:D. I have seen examples and have been able to figure out some of the syntax with trial and error, but I clear explaination would be very helpful. For example I sometimes see a period at the end of a variable. Sometimes I see two periods. Sometimes variables are quoted, sometimes they are not. If I knew the actual syntax rules, it would really be helpful. I have never actually found any examples of windows to windows copy processes in the System Guide or Language Reference.

     

    Thanks

    Rob

     

     

    Some examples of wildcard copies with a bit of description can be found at Wildcard Copies from Microsoft Windows to UNIX or Wildcard Copy from Microsoft Windows to Microsoft Windows.
    You cannot really rename files on a wildcard copy. The source file names will be used for the destination file names, too. They will be appended to whatever you specified on the TO FILE.

    The dot (.) is used as a delimiter to declare the end of a variable name, like "&Time." in your process. Useful when the variable is embedded in some text and the parser does not know where the name of your variable ends, like in "My&TimeIsNow".
    In your case, "D&Date.&Time..txt" will resolve to "D" + <value of &Date> + <value of &Time> + ".txt", for example "D1131211144816.txt"

    Enclosing text and variables in double-quotes is recommended when they contain white spaces, such as blanks. Similar like you would do for Windows filenames.