I need a powershell command to replace unicode chars in a file name to a blank space

Can anyone provide me with a powershell command which will search and replace a specific unicode character in a file name to just a blank space?
Thanks

Hi Roadster198,
In addition, if you want to search and rename the text files under a folder, please also check this script:
Get-ChildItem -Path d:\test1\1\*.txt -Recurse| where{$_.name -like "*ф*"}|rename-item -newname { $_.name -replace "ф"," " }
If there is anything else regarding this issue, please feel free to post back.
Best Regards,
Anna Wang
TechNet Community Support

Similar Messages

  • [SOLVED] Find and replace quotes with underscores in file names

    I was looking to replace all of the quotes in file names in a directory with underscores.  I seem to be having a problem doing so, though.  Running the find command:
    find . -name '*[\`\'\"]*' -exec sh -c "mv -i '$0' '${0//[\`\'\"]/_}'" {} \;
    I get a > inviting me to continue the command.  What am I doing wrong?
    Last edited by gogi-goji (2010-01-03 02:19:13)

    @lolilolicon: yeah the -exec part does give another level of quotes, so you can run into trouble with scripts inside -exec.
    I didn't know you could give {} as an argument after sh -c and $0, that solves the problem of not knowing which quotes to use around it in the -exec part.
    $ find -mindepth 1 -exec sh -c 'mv -v --backup=t "$0" "$(echo "$0" | sed s/[\\x27\"\`]/___/g)"' {} \;
    mv: `./a b' and `./a b' are the same file
    `./\'' -> `./___'
    `./\'"\'' -> `./_________'
    mv: `./$0' and `./$0' are the same file
    mv: `./a' and `./a' are the same file
    mv: `./$(echo crash)' and `./$(echo crash)' are the same file
    `./"' -> `./___' (backup: `./___.~1~')
    `./\'\'\'' -> `./_________' (backup: `./_________.~1~')
    Or with the other substitution method, it doesn't interpret \x27 (you could use $(echo -e \\x27) or you have to use ...'\\\''...
    $ find -mindepth 1 -exec sh -c 'echo mv -v --backup=t "$0" "${0//['\\\''\"\`]/___}"' {} \;
    $ find -mindepth 1 -exec sh -c 'echo mv -v --backup=t "$0" "${0//[$(echo -e \\x27)\"\`]/___}"' {} \;
    mv -v --backup=t ./a b ./a b
    mv -v --backup=t ./' ./___
    mv -v --backup=t ./___ ./___
    mv -v --backup=t ./'"' ./_________
    mv -v --backup=t ./$0 ./$0
    mv -v --backup=t ./___.~1~ ./___.~1~
    mv -v --backup=t ./a ./a
    mv -v --backup=t ./$(echo crash) ./$(echo crash)
    mv -v --backup=t ./_________ ./_________
    mv -v --backup=t ./" ./___
    mv -v --backup=t ./''' ./_________
    mv -v --backup=t ./_________.~1~ ./_________.~1~

  • Replace not latin characters from file name.

    Dear friends,
    I tried a lot but even after reading the documentation about all the available CF functions I could not find a way  to accomplish this:
    As you already know from my previous post I'm trying to finish an application which manages multiple images. I have reached a really good point and I was ready to implement the solutions you suggest on this post when the client did something marvellous. He uploaded some images named "Εικόνα 123.jpg" (Image 123.jpg in English) which actually broke the Flex application that retrieves the images because the firewall does not allow high bit characters to go through. I now need to add a function that will evaluate every character in the file name individually and it will remove or replace (I do not care) all the characters that are not latin or numbers (spaces, greek characters, special characters, etc). As I've already said no known function is able to do that (as far as I know of course) and I guess that the solution could be hiding in regular expressions which is not my strong point. So I need your help here.
    Thank you in advance,
    John

    Thanks Ian,
    I cannot figure out how to use asc() function for this. I will have to run a test in every single character and replace the invalid ones but I will never now the actual string length (how many characters each image name will have) and I will  possibly end up destroying the extensions (.jpg) as well. To make it a little more complicated let me tell you that I will have to run this twice. Once for the full image path (ie d:\company\aptown\images\Εικόνα 123.jpg) in which I will have to change only the ...Εικόνα 123... part and not anything else, and once for a comma separated list of the image names (ie Εικόνα 123.jpg, Εικόνα 124.jpg, Εικόνα 125.jpg, Εικόνα 126.jpg). And don't be misleaded from the pattern. The customer may upload an image named with a complitely different way using invalid characters though, for example "Αντίγραφο της Εικόνας 123.jpg" (Copy of the image 123.jpg in English).
    Seems to be impossible ,
    I hope it is not.
    Yannis

  • Need to remove sixth and remaining characters from a PDF file name

    Typical file name:
    1925a - SomeotherTextHere.pdf
    Need to remove everything after and including the "-" symbol or the sixth position.
    I've tried this but to no avail:
    var filePath = this.path.replace(this.documentFileName,"");
    var newFileName = this.documentFileName.substring(0,6);
    this.saveAs(filePath + newFileName);
    Thanks in advance,
    Russell

    You were right......but a quick question. Why does this work without it? Thanks again!!!
    var filePath = this.path.replace(this.documentFileName,"");
    var newFileName = this.documentFileName.substring(1);
    this.saveAs(filePath + newFileName);

  • How to replace the end of a file name

    I have a seriously dumb question...
    I have a row of thousands of file names (top-down, row a), these names are, for example, "photo-1.jpg" and I need to change the .jpg to .nef. How can I accomplish this?
    thanks!!

    Or just use this 'Find Replace in Selection' Automator Service (Dropbox download) without having to fuss about taking columns out to another app, fiddling with them there, and bring them back in.
    It is just a short AppleScript that, after a quick installation, will look like this in your menu:
    Select the cells where you want to make the replacement, choose 'Find Replace in Selection' from the menu, and enter the find-replace values when prompted. In your case you will see something like this:
    Hit OK and you're done.
    One-time installation is just a doubleclick on the .workflow package.
    Depending on your settings you may have to go to System Preferences > Security & Privacy and click 'Open Anyway'.
    'Install' simply moves the script to your Library > Services folder so it will show up in your Numbers menu.  It doesn't do anything to the innards of your computer.  If you want, you can check out the script first by choosing 'Open with Automator'.
    Since this (obviously) changes values in your document you might want to test it first to make sure it is working as you want.
    If you need to get rid of it then in Finder hold down the option key, choose Go in the menu and navigate to Library > Services, where you can trash it the way you would any other file or package in Finder.
    SG
    Edit: use jpg and nef rather than .jpg and .nef.

  • How to replace first letters of a file name using Power shell or CMD

    Hi guys i am having a problem on mane files that i have which are duplicated. The main reason i cant group them by name is because they have numbers in front of their name which differs Eg
    01 - fileName.txt
    09 - fileName.txt
    02 - fileName.txt
    11 - fileName.txt
    i have a shed loads of them and would like to rename them by deleting the first three characters if they are numbers. I managed to create a powershell script to do that but the problem was that it would not work properly because the file would have a duplicated
    name after deleting the first few chars.
    can anyone help with a better script which would add a number to the end of the file name eg:
    fileName1.txt
    fileName2.txt
    fileName3.txt
    Ps all the files start with two numbers followed by a dash, however i have manually done a few which does not start with numbers and should be left alone by the script
    Thank you

    Here's a quick way to do it. I'm not sure what your existing code looks like but it sounds like you could incorporate this line into it.
    if ($oldfilename -match "[0-9]")
    $newfilename = $oldfilename.split("-")[1].trim().split(".")[0] + $oldfilename.split("-")[0].trim() + "." + $oldfilename.split("-")[1].trim().split(".")[1]
    else
    $newfilename = $oldfilename
    01 - fileName.txt becomes fileName01.txt
    fileName.txt stays fileName.txt

  • Underscore randomly replaces forward slash in topic file names and topic titles

    The problem I'm seeing is similar to the discussion at http://forums.adobe.com/message/2564701 which dealt with random insertion of underscores in topic titles. That problem seemed restricted to underscores replacing spaces in Topic File names and was solved (for some people at least) by deselecting the setting   "Tools > Options > General > Use underscores in filenames." Playing with that setting has not worked for me when it comes to unwanted replacement of forward slashes.
    I'm running RoboHelp 9 and linking from FrameMaker 10. The unwanted underscores are seen in (1) the RH project and (2) the help output:
    (1) In RH project in some topic titles like this:
    I want to keep the forward slash. The upper topic title is wrong and the bottom one is correct.
    (2) In AIR Help output: search results and in the tab that appears above the breadcrumbs in the main right pane.
    I cant change the titles prior to generating output because, as Matt Sullivan wrote in the similar discussion, "...for topics created from linked FrameMaker 9 files, the Topic Title is not editable from the Topic Properties. If it was, at least I could change the offending titles prior to final generation of output. (though the titles would revert on the next update of the FrameMaker source content)."
    I've double-checked the source FrameMaker documents and I can find no difference between Headings in which the forward slash is retained (desired) and those in which the forward slash is replaced by an underscore (unwanted).  Has anyone else seen this?
    Thanks,
    Matt

    Isn't the issue here that RH is creating filenames AND topic titles based on the FM title. Because of the slash it is saying that is an illegal character it changes the filename and the title in RH is based on that, hence both change.
    I don't know if that can be changed but now you can test to see if that is what is happening.
    See www.grainge.org for RoboHelp and Authoring tips
    @petergrainge

  • Need powershell commands to get email addresses from public folder created in EAC to CSV

    Need powershell commands to get email addresses from public folder created in EAC to CSV
    1. Created Public folders via EAC - not mail enabled - just to hold contacts.
    2. Assigned owners and showed to add new contacts - then add to favorites and finally to display as address book.
    Now I need a powershell command to get those email contacts in those public folders.
    I need to view them because when we send emails to those groups (via select all) in the public folders, it is creating an NDR for 3 users saying - "..blah blah -OFFICE FAX or HOME FAX) - yet they are getting the emails.
    I suspect that their contact details are corrupt somehow and want to see what contacts are actually listed in the public folders. I already checked to see if the source of the contacts was the public folder or "my contacts" and they are not.'
    I have tried multiple get recipient commands and get public folder commands with no results in the CSV

    The only way to get that data is either via the Outlook com object or using EWS. None of the commands in the Exchange shell look inside of a folder, the most you can get with those is email addresses for mail-enabled Public folders. Here is a link that can
    get you started with how to connect to public folders via EWS, then its just enumerating the folders and looping through the items in the folders for the details of the items. 
    http://gsexdev.blogspot.com/2013/08/public-folder-ews-how-to-rollup-part-1.html
    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com

  • Get-InboxRule Powershell Command To Display all Rules

    Hello,
    I am in need a powershell command that display all InboxRules per mailbox database. I want to export the information to a CSV and show DisplayName,IsValid,Name,From,RedirectTo as the the column names.
    I found this great article below but I have been unable to pull additional information like the DisplayName. 
    http://blogs.msdn.com/b/canberrapfe/archive/2012/11/05/ever-needed-to-find-server-side-outlook-rules-that-forward-mail-outside-of-your-organisation.aspx
    Any assistance would be greatly appreciated.
    This is what I have been working with so far.
    Get-MailboxDatabase -Identity 'db-f' | Get-Mailbox -ResultSize unlimited  | Get-InboxRule -ErrorAction:SilentlyContinue | Select-Object
    DisplayName, isvalid, @{Name="Forward To";Expression={[string]::join(";",($_.ForwardTo))}} | Export-Csv filename.csv
    Jason

    From the output you are selecting, it appears you are trying to pull rules that forward items to other recipients.  If this is the case, there is no value "DisplayName" returned by the Get-InboxRule command, so what you're going to need
    to do is put bits of information together into the data you want.  Try the following and see if it gives you something workable:
    $MbxDbs = Get-MailboxDatabase
    $MbxDbs | % {
        $DbName = $_.Name
        $DbMbxs = Get-Mailbox -Database $DbName
        $DbMbxs | % {
            $MbxName = $_.Name
            Get-InboxRule -Mailbox $MbxName
        } | Select @{E={ $DbName };L='Database'}, @{E={ $MbxName };L='DisplayName'}, $IsValid, `
            @{Name="ForwardTo";Expression={[string]::join(";",($_.ForwardTo))}}
    } | Export-Csv filename.csv
    In addition to the mailbox display name, I've written this to run through all databases, and added the database to the information returned, to show how you might pull other info into your CSV.  Notice from the Get-InboxRule output (Get-InboxRule
    | Get-Member) that there is also a MailboxOwnerId property, which holds the ADObjectID of the account owning the mailbox.  However, this is the DN of the account, which isn't as clean and readable as the mailbox's DisplayName property,
    which the above returns in the $MbxName = $_.Name line of code.
    If I'm barking up the wrong tree here, feel free to let me know.

  • Deploying via powershell command from AppV Management Server 5.0

    Hello All,
    Good day!
    I am having hard time in deploying an application from AppV Management Server 5.0 using Powershell command.
    I have an application which works in Standalone client machine and even from SCCM 2012(AppV Deployment), whereas if I deploy that application from AppV server it is not working
    I am using this command line to deploy an application from AppV Mgmt server thru powershell command,
    Import-AppvServerPackage -PackagePath "<Path of .appv file>" –DynamicDeploymentConfigurationPath "<Path of DeploymentConfig.xml"> | Publish-AppvServerPackage -Verbose | Grant-AppvServerPackage -Groups "domain\AppV_Users"
    -Verbose
    is there anything wrong in the command which I used?
    When I run, am receiving this error.
    Import-AppvServerPackage : A parameter cannot be found that matches parameter name
    'DynamicDeploymentConfigurationPath'.
    At line:1 char:126
    + ... 1.0.3333.appv" –DynamicDeploymentConfigurationPath '\App_DeploymentConfig.xml'  ...
    +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Import-AppvServerPackage], ParameterBindingException
        + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.AppV.Server.Cmdlets.ImportAppvServerPackageCommand
    whereas this command works, without DynamicDeploymentConfigurationPath
    Import-AppvServerPackage -PackagePath "<Path of .appv file>" | Publish-AppvServerPackage -Verbose | Grant-AppvServerPackage -Groups "domain\AppV_Users" -Verbose
    How do I direct my application to take the DeploymentConfig.xml file though powershell.
    I even tried to Import this xml from AppV Management console, even it did not work for me. 
    Kindly help me, your inputs needed.
    Any help would be greatly appreciated.
    Thanks in Advance!
    Regards,
    Raj

    Hi Falko,
    Thanks for your response.
    As you said, I tried to import the package and used set-appvserverpackage
    PS C:\Users\Administrator.xxxxxxxxxxx> Import-AppvServerPackage "\\appv\Content\Filezilla\Filezilla.appv"
    Id               : 15
    Name             : Filezilla
    Description      :
    PackageGuid      : e8720679-cc41-4578-98a4-32a382f790ef
    VersionGuid      : 296708bc-e07d-474a-bb46-1f09d9779a4c
    Version          : 0.0.0.1
    Enabled          : False
    Applications     : {}
    Entitlements     : {}
    ConnectionGroups : {}
    PackageUrl       : \\appv\Content\Filezilla\Filezilla.appv
    import was successful, when I try Set-Appvserverpackage am receiving the following error
    PS C:\Users\Administrator.xxxxxxxxxxx> Set-AppvServerPackage -DynamicDeploymentConfigurationPath "\\appv\Conte
    nt\Filezilla\Filezilla_DeploymentConfig.xml" | Publish-AppvServerPackage -Global
    Set-AppvServerPackage : Parameter set cannot be resolved using the specified named parameters.
    At line:1 char:1
    + Set-AppvServerPackage -DynamicDeploymentConfigurationPath "\\appv\Content ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidArgument: (:) [Set-AppvServerPackage], ParameterBindingException
        + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.AppV.Server.Cmdlets.SetAppvServerPackageCommand
    I am going wrong somewhere...

  • Need Target File  Name  Timestamp  is  same  as Source File name Timestamp

    Hi ,
           I want to genereate Target file name (Target_09062008082030.xml)   but  this time stamp is exactly Sorce FileTime stamp..(Source_09062008082030.xml)..
         so, i want to create a  target file  with the same source file time stamp.. 
    for this.. i sed Message Specific attributes... in both sender and receiver side.. but  that was creating with the complete name.of source file name.. but i want only Timestamp of the source filename... and remaing is the constant.. for this  how can i proceed  ..
    Thanks
    Jain

    See in Sender CC when you set the Adapter Specific Message Attr  for file name it will send the filename in the header of the XI Message.
    To acces this file name inside mapping you need to create a UDF . The type can be any thing as you desire.
    You dont need to pass any variable .if suppose you want the file name (constant) e.g ABC_<timestamp>.xml
    DynamicConfiguration conf = (DynamicConfiguration) container.getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
    DynamicConfigurationKey key = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName");
    String fileName= conf.get(key);
    //see above your key is FileName which will be sent by the sender CC automatically... You are simply accessing it here using get() method.
    //now ur filename will contain name of the source file... you need to perform a substring operation to get the timestamp and create a new file name as you desire.
    fileName = "New_<timestmp>.xml"; //for e.g
    //set this file name again in header message using put()
    conf.put(key, fileName);
    //when you check on the adapter specific message attr for fileName in the receiver CC ,it will automatically take this new file name value.
    return fileName;
    // if you want to use this new fileName inside your mapping payload (for other fields) you can assign this to any target field,else just assign it to the root tag which will make no difference if this file name is not used anywhere.

  • BLOB unicode file name problem

    Hi,
           I am trying to upload pdf file into SecureLOB column, I am getting error when I try to upload file name/directory  with unicode char, for other files/directory it works fine.
    w_src_loc := bfilename('LDIR', in_file_name);
      dbms_lob.open(w_src_loc, dbms_lob.lob_readonly);
    dbms_lob.open gives file not found error in oracle 11g,
    Can any one guide me what may be the problem?
    DB's character set:
    NLS_CHARACTERSET
    AL32UTF8
    NLS_NCHAR_CHARACTERSET
    AL16UTF16
    P.S. Oracle is running in Windows and unicode (chinese) enabled OS.
    -Raj

    > I am getting error when I try to upload file name/directory  with unicode char,
    ERROR? What Error?
    I do not see any error.
    my car won't go
    tell me how to make my car go.
    How do I ask a question on the forums?
    https://forums.oracle.com/message/9362002#9362002

  • How to user PowerShell -replace to remove the dreaded em dash from a file name?

    I have a bunch of .msg files in a directory and want to zip them up (to send them to our spam filtering company), but I keep getting errors on file names that contain the em dash (—).  I believe it's (char)0x2014.
    [edited]... the correct syntax is [char]0x2014.
    I wish to eliminate the em dash in the file name but I can't seem to find anything on the web about replacing em dashes.  When I paste '—', PowerShell replaces it with a '-'.
    I found this neat function that does a great job replacing multiple characters within a string.
    http://powershell.com/cs/blogs/tobias/archive/2011/04/28/multiple-text-replacement-challenge.aspx
    I am using the below code for my string replacement.
    Thank you for your help.
    function Replace-Text {
    param(
    [Parameter(Mandatory=$true)]
    $text,
    $replacementlist = "(-,,',,%,,$,,@,,#,,&,,’,"
    Invoke-Expression ('$text' + -join $(
    foreach($e in $replacementlist.Split(',')) {
    '.Replace("{0}","{1}")' -f $e, $(
    [void]$foreach.MoveNext()
    $foreach.Current)
    $path = '<path>'
    Get-ChildItem -Path $path | Rename-Item -NewName {(Replace-Text $_.Name).trim()}

    Here is a simple filter that will strip out all nonprintable chanracters.
    $newname=$file.Name -replace '[^a-zA-Z\.]'
    I just tested it on Win 7 which supports has a Unicode filesystem and it successfullstrips the bad characters.
    We also need to do this on files uploaded to SharePoint and OneDrive.
    The ~ and other similar characters are not allowed in may systems.  You should keep a translation log and tag all renamed files with some obvious tag.
    ¯\_(ツ)_/¯

  • Powershell command to migrate Exchange 2007 mailbox databases with a legacy name, & import them into a new 2007 instance, with a new name.

    Hi All. I am currently at the later stage of provisioning a new CCR Exchange 2007 migration (to
    virtualise old Exchange 2007 hardware) for 5,000 users & have a quick question.
    I have created around 15 newly named storage groups, & have named 1 new DB per group, with the same name (let's say New-DB-1), residing within them.  The problem I have, is the old legacy DB's have different names (let's say Old-DB-1) & I need
    to import them into the new storage groups, to match the new names. So far I can import/export between old & new OK if both old & new DB names\folders etc. names marry up perfectly, but are unable to if there not the same. Does anyone have any thoughts
    on how best to tackle this, as this is one of the final hurdles stopping the migration? Many Thanks, John 

    Hi All
    Many Thanks for the feedback.
    The terminology 'migrate' was used based around the fact I will be decommissioning the old 2007 physical environment. This is after moving all DB's over to the new newly created Virtual environment that will host all roles.
    The solution I ended up using yesterday, was the following:
    1) Dismounted the relevant named DB (NEWDB) in the new environment.
    2) I then ticked the 'This database can be overwritten by a restore option' box.
    3) Copied over the old named DB (OLDDB) to the same location, & overwrote using the new name (NEWDB).
    4) Re-mounted the (NEWDB).
    5) Ran the following 2 PowerShell commands:
     Get-mailbox –database OLDDB | move-mailbox –targetdatabase NEWDB -configurationonly:$true
     Get-MailboxDatabase NEWDB | ResetSearchIndex.ps1 -force
    6) Checked to make sure the clients were working ok, in the now the new (NEWDB) environment.
    Rich: Many thanks for your PS script, which I will test with future DB moves & provide feedback
    J
    John.

  • How to get Systemstate Backup size using PowerShell command in Windows 2008 R2

    Hi,
    We using WBSummary command to get completed backup status.
    I need to find how much data is backed up  using powerShell command .
    Is there any way to get the details , i can see the GUI but no in command.
    Please advise
    Regards Gopi K

    Hi,
    You mentioned that you can see the system state backup size in the GUI. Does the backup size mean the amount of date transferred?
    It seems that there is no such a PowerShell to get Systemstate Backup size. You may need to you need a PowerShell scripts to do this work.
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/home?forum=ITCG
    Regards,
    Mandy
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • Creating a Custom CharsetProvider

    I am led to believe that using the java.nio package, creating and registering a new custom CharsetProvider is a breeze ;) All I want to do, is register a custom Charset, which will be used to encode three Danish characters into specific byte values.

  • Equium A60: Blue Screen issue

    I've got a Equium A60 Series (PSA667E), reconditioned. There's a blue screen apearing sometimes, when I start up, sending me a message of error. I've tried to upgrade my BIOS, as the website indicated. But a message tell me that I dont need, because

  • Poor DVD Quality for slide shows from quicktime

    I have generated a slide show in QT and the quality is great. When I try to generate a DVD the quality drops significantly (very disappointing). How do I generate highest quality DVDs especially for slideshows. Any help would be greatly appreciated.

  • Apple Configurator report of the apps that are available/downloaded

    is it possible to generate a report in Apple Configurator of the apps that are available/downloaded?

  • Help with EXECUTE IMMEDIATE and DROP

    Hi all, we are trying to create a procedure to do the following: * We have in the database some tables named like C$_XXXXXXXXX * We want to drop some of these tables that have a common prefix (f.e C$_1203101) DECLARE v_sql VARCHAR2(300); BEGIN SELECT