Sanitizing an input to create a valid output file name

I have a function that creates an ACL permission table X levels deep given a root folder and how many levels you'd like to go. I want to name the output file based on the root folder given, but obviously file names can't have certain characters in them.
How do I replace all "< > : " / \ | ? *" characters with
underscores? 
[email protected]

If anyone cares, here's my final code:
Function Get-FoldersToDepth {
Param(
[String]$Path = $PWD,
[String]$Filter = "*",
[Byte]$ToDepth = 255,
[Byte]$CurrentDepth = 0,
[Switch]$DebugMode
$CurrentDepth++
If ($DebugMode) { $DebugPreference = "Continue" }
Get-ChildItem -Directory $Path | %{
$_ | ?{ $_.Name -Like $Filter }
If ($_.PsIsContainer) {
If ($CurrentDepth -le $ToDepth) {
# Callback to this function
Get-FoldersToDepth -Path $_.FullName -Filter $Filter `
-ToDepth $ToDepth -CurrentDepth $CurrentDepth
} Else {
Write-Debug $("Skipping GCI for Folder: $($_.FullName) " + `
"(Why: Current depth $CurrentDepth vs limit depth $ToDepth)")
$date = get-date -UFormat "%d.%m.%Y"
$a = "<style>"
$a = $a + "BODY{background-color: #F0F0F0;}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: #D0D0D0;border-collapse: collapse;padding: 2px}"
$a = $a + "TH{border-width: 1px;padding: 2px;border-style: solid;border-color: #D0D0D0;background-color: #BFFFFF}"
$a = $a + "TD{border-width: 1px;padding: 2px;border-style: solid;border-color: #D0D0D0;background-color: #BFBFBF}"
$a = $a + "</style>"
Function CreatePermissionMap {
Param(
[string]$Path = $PWD,
[string]$filter = "*",
[Byte]$ToDepth = 255
$folderprep = get-folderstodepth -path $path -ToDepth $ToDepth -filter $filter
$folders = $folderprep.fullname
$output = $path -replace '[<>:"/\\|?*]','_'
ForEach ($folder in $folders)
get-accesscontrolentry -InputObject $folder | select path, principal, AceType, AccessMaskDisplay, AppliesTo | ConvertTo-Html -Head $a -body "<H2>ACL entries for: $folder</H2>" | out-file -Append h:\powershell\temp\$output.$date.html
I'm likely to spend the next 2 hours figuring out how to make all those tables line up
[email protected]

Similar Messages

  • Require output file name same as input file without extension

    I am doing a POC where I require that my output file name should be same as input file name. The input is a XML and output is Flatfile. If I use %SourceFileName%,
    i am getting the output with extension. How can I remove the extension? Do I need to write a custom pipeline component?

    I don't think Orchestration or custom Pipeline can help you on this as  you are setting
    %SourceFileName% Macros at your send Handler which comes after Pipeline Processing .
    As you are converting xml file to Flat file I would suggest to use  Macros  as
    %SourceFileName%.txt 
    %SourceFileName% Macro gives the file name along with extention. This won't work!

  • Configure:3955: checking for C compiler default output file name

    Hi,
    I am trying to configure oracle bsd on AIX and got the below error,
    # sh /ldap/db-4.6.21.NC/dist/configure
    checking build system type... powerpc-ibm-aix5.3.0.0
    checking host system type... powerpc-ibm-aix5.3.0.0
    checking if building in the top-level or dist directories... no
    checking if --disable-cryptography option specified... no
    checking if --disable-hash option specified... no
    checking if --disable-mutexsupport option specified... no
    checking if --disable-queue option specified... no
    checking if --disable-replication option specified... no
    checking if --disable-statistics option specified... no
    checking if --disable-verify option specified... no
    checking if --enable-compat185 option specified... no
    checking if --enable-cxx option specified... no
    checking if --enable-debug option specified... no
    checking if --enable-debug_rop option specified... no
    checking if --enable-debug_wop option specified... no
    checking if --enable-diagnostic option specified... no
    checking if --enable-dump185 option specified... no
    checking if --enable-java option specified... no
    checking if --enable-mingw option specified... no
    checking if --enable-fine_grained_lock_manager option specified... no
    checking if --enable-o_direct option specified... no
    checking if --enable-posixmutexes option specified... no
    checking if --enable-pthread_api option specified... no
    checking if --enable-rpc option specified... no
    checking if --enable-smallbuild option specified... no
    checking if --enable-tcl option specified... no
    checking if --enable-test option specified... no
    checking if --enable-uimutexes option specified... no
    checking if --enable-umrw option specified... no
    checking if --with-mutex=MUTEX option specified... no
    checking if --with-tcl=DIR option specified... no
    checking if --with-uniquename=NAME option specified... no
    checking for chmod... chmod
    checking for cp... cp
    checking for ln... ln
    checking for mkdir... mkdir
    checking for rm... rm
    checking for sh... /usr/bin/sh
    checking for a BSD-compatible install... /ldap/db-4.6.21.NC/dist/install-sh -c
    checking for C compiler default output file name...
    configure: error: C compiler cannot create executables
    See `config.log' for more details.
    and in config.log,
    configure:3955: checking for C compiler default output file name
    configure:3982: xlc_r -O2 -D_THREAD_SAFE -Wl,-brtl conftest.c >&5
    /ldap/db-4.6.21.NC/dist/configure[3983]: xlc_r: not found
    configure:3985: $? = 127
    configure:4023: result:
    configure: failed program was:
    | /* confdefs.h. */
    | #define PACKAGE_NAME "Berkeley DB"
    | #define PACKAGE_TARNAME "db-4.6.21"
    | #define PACKAGE_VERSION "4.6.21"
    | #define PACKAGE_STRING "Berkeley DB 4.6.21"
    | #define PACKAGE_BUGREPORT "Oracle Technology Network Berkeley DB forum"
    | #define HAVE_UPGRADE_SUPPORT 1
    | /* end confdefs.h. */
    |
    Is this beacase valid c compiler not existing?
    # which cc
    which: 0652-141 There is no cc in /usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin /usr/java14/jre/bin /usr/java14/bin.
    # ksh: which:: not found.
    # which c
    which: 0652-141 There is no c in /usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin /usr/java14/jre/bin /usr/java14/bin.
    Thanks,
    Message was edited by:
    GK Joe

    Joe,
    I presume you are trying to build Oracle BDB and not bsd as you have mentioned.
    Yes, the error message you are getting is for not having the CC compiler in your system or the path isn't set. Check in the /usr/vac/bin directory if you have one in your system. You might find both xlc and cc compiler there. Set this directory to your path so that 'configure' can see it.
    Regards,
    -Debsubhra

  • How to get the Output File Name as One of the Field Value From Payload

    Hi All,
    I want to get the Output file name as one of the Field value from payload.
    Example:
    Source XML
    <?xml version="1.0" encoding="UTF-8" ?>
    - <ns0:MT_TEST xmlns:ns0="http://sample.com">
    - <Header>
      <NAME>Bopanna</NAME>
      </Header>
      </ns0:MT_TEST>
    I want to get the Output file name as " Bopanna.xml"
    Please suggest me on this.
    Regards
    Bopanna

    Hi,
    There are couple of links already available for this. Just for info see the below details,
    The Output file name could be used from the field value of payload. For this you need to use the UDF DynamicFile name with below code,
    //       Description: Function to create dynamic Filename
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File" , "FileName");
    conf.put(key,a);
    return "";
    With this udf map it with the MessageType as
    (File Name field from Payload) > DynamicFileConfiguration>MTReceiver
    Thanks
    Swarup

  • Output file name format

    Hi All,
    How can i configure output file name to the desired format generated in target directory in communication channel configuration in conf scenario.
    ex: i want to generate the file in the below format..
    YYYYMMDD_<Receiver>.TXT
    Thanks and Regards
    Venkatesh

    Hi,
    This is the UDF u have to write in Mapping,
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key =
    DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String ourSourceFileName = conf.get(key);
    return  ourSourceFileName;
    Using this u will get the File name into target side,In this UDF add the Time stamp.
    Check this link for more details.
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Regards,
    phani
    Reward points if Helpful

  • Setting output file name in export transaction data package

    Hi all,
    I am running an "export transaction data" package in the data manager. I wanted to set the output file name so that it will be a constant value. I wrote the following in the package editor:
    INFO(%FILE%,\ROOT\WEBFOLDERS\COLMOBIL\VEHICLES1\DATAMANGER\DATAFILES\vehicles_to_pca2.txt)
    TASK(/CPMB/TD_FILE_TARGET,FULLFILENAME,%FILE%)
    The system run the package and reported success but the file was not created. When i did the same with an existing file name, it was not updated.
    When I run the same package with the following PROMPT command instead of the INFO command:
    PROMPT(OUTFILE,,"Please enter an output file",Data files (*.txt)|*.txt|All files(*.*)|*.*)
    The system works fine.
    Any ideas?
    TIA
    Avihay

    I am sad to report that apparently Adobe does not do a very good job with the PDF printer. I have just spent over an hour with support to get the answer we can not help you. I guess I will have to spend $50 for NovaPDF to handle my problem. It's a shame when a superior overall product like Acrobat is not able to keep up with the knockoffs on the small things.

  • How to programmatically disable prompts for output file names in Acrobat X

    My code to programmatically disable output file names (below) is not working on a Windows 7 64-bit machine using Acrobat Distiller X.  It works perfectly on a Windows XP machine with Acrobat Distiller 8.
    The latest API Reference I was able to find is dated June 2008.  My logic follows this convention.
    I have confirmed that the registry key is updated as specified below.  I have also confirmed that I am able to write to the directory indicated.
    Please provide any suggestions to resolve. 
    Thank You!
    ~Lori
    'Create the Registry Key where Acrobat looks for a file name
            CreateNewRegistryKey HKEY_CURRENT_USER, _
                         "Software\Adobe\Acrobat Distiller\PrinterJobControl"
    'Put the output filename (FilePath) where Acrobat could find it
            SetRegistryValue HKEY_CURRENT_USER, _
                     "Software\Adobe\Acrobat Distiller\PrinterJobControl", _
                     C:\Program Files (x86)\Microsoft Office\Office12\MSACCESS.EXE, _
                     T:\PDF Files\Current Week\NFS_Lori,Test.pdf

    I remember seeing that the problem is thunking. A little more specifically, because it's a 32-bit driver but a 64-bit executable, there's a 32-bit system spooler process which will always show up as the EXE name.

  • Dynamic output file name for scheduling a BIP report

    Hi All,
    I have a BI Publisher report. It has Department as prompt. we need to run the report for each department. I need to schedule the report such that, for each department i need to FTP the output with file name as department_INFO.pdf in the one folder (i.e. if dept is ABC, then i need to store the output with file name as ABC_INFO.pdf and ftp to the folder). Folder will be created already in the server.
    We have around 40 departments, so i need to manually schedule this report 40 times with 40 files names and ftp the output to the folder in the server.
    Can we dynamacally give the output file name based on the prompt we are using to run, instead of manually scheduling for each department.
    Please help me ASAP..we cant move further due to this problem.
    Regards,
    Sandy

    .

  • REG: Output File Name

    Hi All,
              I have a file to file scenario where mapping is not used. My  Input file name is "XXXX.txt" and i want the output file name as "XXXX.dat". But the problem is XXXX is not a constant value but a dynamic value and i cant use a UDF because there is no mapping for this interface. Is there any other method by which this can be achived?
    Thanks,
    Siva

    Hi!
    For your input file you can work as follows:
    Put the file in a special directory and then read this directory using wildcard filename definition:
    e.g. *.txt looks for and processes all files ending with *.txt
    For your output file (receiver file adapter) you may work with os command "rename" and/or try it using this stuff:
    http://help.sap.com/saphelp_nwpi71/helpdata/en/44/6a316af5a23672e10000000a114a6b/content.htm
    Regards,
    Volker

  • Dynamic report output file name

    Hi,
    I am generating a report using web interface by sending http string with required parameters.
    Each time I run this report I am appending current date & time (mmddyyhhmm) string to the output file name.
    Successfully I am able to get the outputs.
    For example:
    If report runs at 9:30am then MyReportOutput_0205040930.html
    If report runs at 12:45pm then MyReportOutput_0205041245.html
    But, I am facing the problem when I schedule the report. I want to append the report run date & time to the output file for scheduled runs.
    Is it possible?
    Please advise.
    Thank you,
    Prasad

    hi,
    for that you will have to use reports distribution. in the distribution XML file you can specify data fields from the report for various attributes, including the output file name.
    you will have to create a column in your datamodel that creates this timestamp and then add it to your report name.
    see the distribution/bursting example here on OTN for further information. click onthe getting started link on the reports homepage and then navigate to the INDEX. there you will find an overview of all the examples available.
    thanks,
    philipp

  • I have an older version of itunes on my L drive.  Everytime I try to download the newest version I get the error itunes.resources is not a valid short file name.  Now I obtained an iphone and cannot sync the phone to my account because it wants me to upda

    I have an older version of itunes on a separate drive.  Everytime that there has been an update to itunes it will not let me update.  Now I purchased an iphone and I hooked the phone up to the computer and it tells me I need to install the latest version of itunes.  I downloaded to try it, but I keep getting an error message that says itunes.Resources is not a valid short file name.  What can I do from here?

    That is a new one on me.
    For general advice see Troubleshooting issues with iTunes for Windows updates.
    The steps in the second box are a guide to removing everything related to iTunes and then rebuilding it which is often a good starting point unless the symptoms indicate a more specific approach. Review the other boxes and the list of support documents further down the page in case one of them applies.
    The further information area has direct links to the current and recent builds in case you have problems downloading, need to revert to an older version or want to try the iTunes for Windows (64-bit - for older video cards) release as a workaround for installation or performance issues, or compatibility with QuickTime or third party software.
    Your library should be unaffected by these steps but there are also links to backup and recovery advice should it be needed.
    tt2

  • "not a valid short file name" and "invalid character" install errors

    Disclaimer: Apple does not necessarily endorse any suggestions, solutions, or third-party software products that may be mentioned in the topic below. Apple encourages you to first seek a solution at Apple Support. The following links are provided as is, with no guarantee of the effectiveness or reliability of the information. Apple does not guarantee that these links will be maintained or functional at any given time. Use the information below at your own discretion.
    Symptoms
    While upgrading or uninstalling a Windows software application (such as iTunes for Windows or QuickTime for Windows), you may receive one of the following error messages:
    file name is not a valid short file name
    The folder path 'folder name' contains an invalid character.
    ... where file name could be the name of any file, and folder name could be the name of any folder.
    In the case of software that uses advertised shortcuts (such as recent versions of iTunes for Windows or Safari for Windows), the messages may also appear when attempting to launch software that has already been installed.
    Resolution
    The error messages are usually caused by damage to the installation database for the application. Clearing the installation database for the application by using the Windows Installer CleanUp utility can usually get you past the error message.
    (1) Click [here|http://support.microsoft.com/kb/290301] first, and read the important information about the utility.
    (2) Click the *Download the Windows Installer Cleanup Utility package now* link on that page to download a file titled msicuu2.exe.
    (3) Open the msicuu2.exe file and follow the prompts to install it.
    (4) In your Start menu click *All Programs* and then click *Windows Install Clean Up.* The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (5) Select the software you're getting the "not a valid short file name" or "invalid character" message for from the list and click Remove.
    (6) Click OK in the confirmation dialog that appears.
    (7) If you have multiple entries for the software you're getting the "not a valid short file name" or "invalid character" message for, repeat steps 5 and 6 for the other entries for the software.
    (8) Click Exit.
    (9) Restart the computer.
    If you were getting the "not a valid short file name" or "invalid character" message when trying to upgrade or launch software, now try reinstalling the latest version of the software.
    If you were getting the "not a valid short file name" or "invalid character" message when just trying to uninstall software, program files for the software in question will remain on the PC after it has been removed by the Windows Installer CleanUp utility. If you want to remove leftover program files, check in at the appropriate forum at [Apple Discussions|http://discussions.apple.com/index.jspa?categoryID=1] and ask which files can be safely removed.
    This is the 1st version of this tip. It was submitted on March 24, 2010 by b noir.
    Do you want to provide feedback on this User Contributed Tip or contribute your own? If you have achieved Level 2 status, visit the User Tips Library Contributions forum for more information.

    Go to Microsoft website to fix installer file problems.
    Click "Run now" from Fix it to remove all iTunes & related installer files:
    http://support.microsoft.com/mats/Program_Install_and_Uninstall
    Be aware that Windows Installer CleanUp Utility will not remove the actual program from your computer. However, it will remove the installation files so that you can start the installation, upgrade, or uninstall over.
    Download and Install iTunes

  • When I open up an e-mail attachment a box pops up PRINT TO FILE below that line OUTPUT FILE NAME with an empty line for the file name vs. simply going to my default printer?

    when I open up an e-mail attachment a box pops up PRINT TO FILE below that line OUTPUT FILE NAME with an empty line for the file name vs. simply going to my default printer?

    Make sure that '''''Print to File''''' isn't selected in the native print dialog box ''(see screenshot below)'' middle-right, and make sure your Printer is selected at the top of that dialog box.
    ''I'm a little confused why an email attachment would need to go directly to the printer, but that's what you asked about.''

  • 'iTunesMiniplayer.Resources' is not a valid short file name

    -deep inhale-
    up until about a month ago i'd used my ipod as a hard drive so i could have iTunes wherever i went. i installed it using my brother's PoS computer (i dunno the specs but it's running windows XP)and it was assigned to drive (F:)
    as soon as i got my netbook i saw no need to keep the program installed on the ipod so i deleted it. now he has an ipod and wants to eliminate cds from his life, but there's one problem: the computer still says itunes is installed at (F:) and will not uninstall or repair. about 4 minutes into the 'installation', an error window pops up saying "'iTunesMiniplayer.Resources' is not a valid short file name."
    six attempts later the installer pops up and asks where to install. as i go to change the location from (E:) another error window tells me that "'(E:)' is not a valid destination. Please choose a new destination." Clicking ok causes the installer to finish and it too warns me of a 'fatal error during installation' and to try again later. i've been stuck at this point for half an hour.
    how do i avoid buying an external disk drive for my netbook to upload his music onto his ipod?

    See if the Windows Installer CleanUp Utility will get rid of itunes.
    Then try the install again.

  • Can I print to AdobePDF with a pre-determined output file name?

    I have a list of PDF files that I need to reduce in size. I have tried many combinations of Adobe's "Save As Reduced PDF", "Save As Optimized PDF", as well as several compression programs. The best results I've found have been to print the PDF via AdobePDF, using the standard quality settings.
    This leads me to my problem. It's simple to batch the print process to print multiple files to AdobePDF, however each one requires the user to specify the output file name. Is there a way to interface with the AdobePDF tool in a way that the output file name is already determined? I.e. passed into the program as an argument? Any help would be greatly appreciated.
    Thanks,
         Dan
    EDIT: Under the Adobe PDF Settings, the option for Adobe PDF OUtput Folder is set for Prompt for Adobe PDF filename. There is also an option to dump to Documents\*.pdf, which retains the original filename. Is there a way to specify a different directory, rather than Documents, while retaining the *.pdf argument? Again, thank you.

    You would probably get better results printing from Acrobat. The HTMLLoader rasterizes the image first. You could possibly add a JavaScript function inside the PDF that prints and call that from your AIR app.
    See http://www.adobe.com/devnet/air/flex/quickstart/scripting_pdf.html for information on calling JS functions in a pdf file from AIR.

Maybe you are looking for

  • Getting the following message on Final Cut Express "audio only capture selected video preview disabled" how can I get the video capture back?

    I'm getting the following message on screen when attempting to capture video  "audio only capture selected, video preview disabled."  How can I get the view preview back?

  • ATP check at sales order by storage location

    Can I do an ATP check against a plant/storage location level during sales order entry?  Basically, for a particular plant, if I have 2 storage location with the following quantities: 0010 = 100ea 0020 = 150ea Can I create a sales order for 110ea, spe

  • StageVideo application crash on mobile devices.

    Hello everyone. The last few months, I've been having trouble with StageVideo on selected Android devices and as of today on all iOS 7 devices. When I try to switch between the currently playing video and a new one, after a random number of toggles,

  • 10g Listener

    Hi all. I have win xp computer on which i instaled 10g RDBMS and then patched it to 10.2.0.3.0 . Then I tryed to create the database with[b] dbca , creation stopped at 2% with : ORA-12560 : TNS: Protocol adapter error, so i started netca to create th

  • Alternative to Substitution Variables

    I'm attempting to loop though some logic X number of times based on a user-defined (defined using substitution variable) parameter. Within the loop I need to have user-definable parameter as well. Since substitution variables cannot be used in a loop