With BizTalk, we often archive files in a sub directory. Personally, I would rather archive to a SQL database with a database column, but that takes a little more architecture and sales. So in the meantime, many clients continue to write files to disk. There are frequently clean-up jobs that delete files over x days old.

However, when there are multiple thousands of a files in any directory, it can take a long time to open that directory, and display the files, especially when you are accessing it from a remote computer.

The $DaysBack parameter can be set to non-zero if you want to only group files over x days old into sub-directories.



You will need full write/rename access to run this script. You can specify a UNC name in the $SourceDir and $DestinationDir variables.

Code above based on code sample found here http://www.marcvalk.net/2012/06/powershell-moving-files-into-subfolder-based-on-date/

Before – could be thousands of files


After – Files in neat subdirectories by date



Error encountered during parsing. The X12 transaction set with id '0001' contained in functional group with id '850009661', in interchange with id '850009661', with sender id '9333516114     ', receiver id '956837686      ' is being suspended with following errors:
Error: 1 (Miscellaneous error)
  4: Number of included segments do not match


Below is an the last few lines of an EDI file in NotePad++. You can do replace ~ with ~\r\n to format to make it more readable (be sure and check the “Search Mode” to “Extended”.


The number after “SE” should be one less than the line it is on. In this case, I removed an MTX segment to test, but didn’t change segment count in the “SE” segment. So if you add or remove segments, you have to update this counter.

If you are getting the error “Invalid queue path name” from C# or other language, it could be that when reference a remote queue, you need to add the “FormatName:DIRECT:OS:” on the front,

Instead of:


Prefix it as shown below


For more details, see “Manabu Tokunaga blog” or “Stack Overflow”

Short blog today, below is working C# code I ran today to format and update a date in an Oracle database.
My first attempt using just DateTime.Now resulted in error “ORA-01861: literal does not match format string”.