Announcement

Collapse
No announcement yet.

Removing each file from a SMB source in postprocessing.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing each file from a SMB source in postprocessing.

    I'm trying to delete files postprocess from a SMB source, was hoping the following will do this, however this is only working for local drives;

    Any ideas?


    Code:
    Code:
    if ($('DCMheaderTag') == "Example1" || $('DCMheaderTag') == "Example2") {
    var originalFile = new java.io.File($('fileDirectory') + '\\' + $('originalFilename'));
    originalFile.delete();
    }
    return false;
    Last edited by Ruffdraft; 06-01-2020, 06:58 AM.

  • #2
    With smb-filereaders the sourceMap variable 'fileDirectory' contains a string like smb://servername/sharename/directory1/directory2/.

    'originalFilename' is the same as with local files. To access (delete) a file you need to insert your credentials into the fileDirectory string and use methods from the CIFS-library

    Code:
    //convert Java string to Javascript string in order to use Javascript string methods
    var dir = String($('fileDirectory'));
    
    var fn = "smb://" + domain + ";" + user + ":" + password + "@" + dir.substring(6); + $('originalFilename');
    var file=new Packages.jcifs.smb.SmbFile(fn);
    file["delete"]();
    The 'domain;' part can be left out if it's a local user.

    Hope this helps.

    Comment


    • #3
      Thanks Schillert

      This worked perfectly!

      Its now removeing files from SMB source once processed by the channel with either DCM head tags.


      Code:
      if ($('DCMheaderTag') == "Example1" || $('DCMheaderTag') == "Example2") {
      //convert Java string to Javascript string in order to use Javascript string methods
      var dir = String($('fileDirectory'));
      var fn = "smb://" + "Domain" + ";" + "User.name" + ":" + "password" + "@" + dir.substring(6) + '//' + $('originalFilename');
      var file=new Packages.jcifs.smb.SmbFile(fn);
      file["delete"]();
      }
      return false;

      Comment

      Working...
      X