Powershell replace text in multiple files lookup CSV

Hiya guys
After some guidance please.
I have a CSV with following details
MailboxName, PRFNAME,TempConstant
usera, a, usera.prf,TEMPLATEPRFUSER
userb, b, userb.prf,TEMPLATEPRFUSER
userc, c, userc.prf,TEMPLATEPRFUSER
Im after creating multiple copies of a prf file with the PRFNAME
Import-Csv $UsernamesCSV | % { Copy-Item "C:\TemplatePRF\Template.prf" "C:\TEST\$($_.NewPRFName)"}
This creates multiple prfs named correctly based on the prfnames provided in the CSV
Now I want to search for mailboxname=TEMPLATEPRFUSER and replace to "MailboxName" from my csv.
so it will be
usera.PRF
ContentsMailboxname=user, a
userb.prf
contents
mailboxname=user, b
So the common field to replace will be TEMPALTEPRF but replace with the relevatnt mailboxname depending on prf name.
After looking around I found the following
Param (
#$List = "C:\TemplatePRF\mailbox.csv",
$Files = "c:\Test\*.prf"
$ReplacementList = Import-Csv $UsernamesCSV;
Get-ChildItem $Files |
ForEach-Object {
$Content = Get-Content -Path $_.FullName;
foreach ($ReplacementItem in $ReplacementList)
$Content = $Content.Replace($ReplacementItem.TEMPConstant, $ReplacementItem.mailboxn)
Set-Content -Path $_.FullName -Value $Content
At the moment all the files will then have the content "mailboxname=" set as user,a and it does not seem to loop through the remaining and replace correctly.

It looks like something along these lines should work, though the CSV data you posted is currently invalid. If you want to have a comma in a field (such as user, a), it needs to be quoted. Otherwise the comma is treated as a delimiter in the CSV.  Generally,
I would recommend just quoting everything, to avoid problems. That's what PowerShell does when you use Export-Csv. Here's the test file I used:
"MailboxName","PRFNAME"
"usera, a","usera.prf"
"userb, b","userb.prf"
"userc, c","userc.prf"
I got rid of the TempConstant field; there's no reason to repeat that data on every line of the CSV file.  It's just hard-coded in the script right now.  Here's the code:
$templateFile = 'C:\TemplatePRF\template.prf'
$csvFile = 'C:\TemplatePRF\mailbox.csv'
$outputDirectory = 'C:\TemplatePRF\New'
if (-not (Test-Path -Path $outputDirectory -PathType Container))
New-Item -Path $outputDirectory -ItemType Directory -ErrorAction Stop
$templateContents = Get-Content -Path $templateFile -ErrorAction Stop
Import-Csv -Path $csvFile |
ForEach-Object {
$record = $_
$newContents = $templateContents -replace '(?<=mailboxname\s*=\s*)%TEMPLATEPRFUSER%', $record.MailboxName
$newFile = Join-Path -Path $outputDirectory -ChildPath $record.PRFNAME
Set-Content -Path $newFile -Value $newContents

Similar Messages

  • Find and replace text in multiple Photoshop files?

    Hi there,
    Let us say I have six Photoshop files: 1.psd, 2.psd, ..., 6.psd. All of these files contain the word “LoremIpsum” in random text layers, within each document. Is there a way I can search for “LoremIpsum” in all documents and replace it with “Dolor Sit Amet”, all in one go? This is just an example, I need to replace various words, not just one.
    I have tried "batch find and replace" software (including powerful tools like Power Grep) but they do not work with psd files… Is there a javascript of external plugin for this kind of task?
    Thanks!

    You’re welcome, advice given here is free.
    If you want to donate something nonetheless you could do so over at
    http://ps-scripts.com/bb/
    Many of the same people used to contribute there as here and I for one have benefitted considerably from their generous advice on Scripting issues.
    A Script can read (or create) txt files, but I do not have a lot of experience with this.
    This might work (amend the line »var theTexts = readPref ("….txt", false);« according to your txt-file’s path):
    // replace text elements in type layers;
    // 2013, use it at your own risk;
    #target photoshop
    if (app.documents.length > 0) {
              for (var n = 0; n < app.documents.length; n++) {
                        app.activeDocument = app.documents[n];
                        app.activeDocument.suspendHistory("replace text", "main()")
    // the opertation;
    function main () {
              var myDocument = app.activeDocument;
              var theTexts = readPref ("….txt", false);
              var theArray1 = theTexts.slice(0, Math.round(theTexts.length/2));
              var theArray2 = theTexts.slice(Math.round(theTexts.length/2), theTexts.length);
              alert (theArray1.join("\n")+"\n\n\n"+theArray2.join("\n"))
              for (var b = 0; b < theArray1.length; b++) {
                        replaceText (theArray1[b], theArray2[b])
    ////// reoplace text //////
    function replaceText (replaceThis, replaceWith) {
    // =======================================================
    var idreplace = stringIDToTypeID( "replace" );
        var desc22 = new ActionDescriptor();
        var idnull = charIDToTypeID( "null" );
            var ref3 = new ActionReference();
            var idPrpr = charIDToTypeID( "Prpr" );
            var idreplace = stringIDToTypeID( "replace" );
            ref3.putProperty( idPrpr, idreplace );
            var idTxLr = charIDToTypeID( "TxLr" );
            var idOrdn = charIDToTypeID( "Ordn" );
            var idAl = charIDToTypeID( "Al  " );
            ref3.putEnumerated( idTxLr, idOrdn, idAl );
        desc22.putReference( idnull, ref3 );
        var idUsng = charIDToTypeID( "Usng" );
            var desc23 = new ActionDescriptor();
            var idfind = stringIDToTypeID( "find" );
            desc23.putString( idfind, replaceThis );
            var idreplace = stringIDToTypeID( "replace" );
            desc23.putString( idreplace, replaceWith );
            var idcheckAll = stringIDToTypeID( "checkAll" );
            desc23.putBoolean( idcheckAll, true );
            var idFwd = charIDToTypeID( "Fwd " );
            desc23.putBoolean( idFwd, true );
            var idcaseSensitive = stringIDToTypeID( "caseSensitive" );
            desc23.putBoolean( idcaseSensitive, false );
            var idwholeWord = stringIDToTypeID( "wholeWord" );
            desc23.putBoolean( idwholeWord, false );
            var idignoreAccents = stringIDToTypeID( "ignoreAccents" );
            desc23.putBoolean( idignoreAccents, true );
        var idfindReplace = stringIDToTypeID( "findReplace" );
        desc22.putObject( idUsng, idfindReplace, desc23 );
    executeAction( idreplace, desc22, DialogModes.NO );
    ////// read prefs file //////
    function readPref (thePath, binary) {
      if (File(thePath).exists == true) {
        var file = File(thePath);
        file.open("r");
        if (binary == true) {file.encoding= 'BINARY'};
        var theText = file.read();
        file.close();
        return String(theText).split(",")
    In this case the comma is used to split the text into Strings in Arrays, if your search/replace texts include commas you could use something else, I guess.

  • Find & Replace text in html files

    This is my first real attempt at using Automator, and it has become increasingly frustrating for me. I love the idea of Automator, nice interface, and it appears to be so easy to use. But, I can't get it to actually DO anything and I don't understand why.
    Here is my goal:
    to batch process multiple html files to remove certain characters and words (or replace them with empty space).
    I currently open these files in Pages and do 6 separate Find & Replace commands for each file before I continue with my other processing tasks. This is very tedious and I believe the computer should be able to find & replace multiple items at one time. (I have used other utilities to do batch renaming and trimming file names before.)
    All I want to do is select a group of files (usually 25 at a time) and have Automator get rid of all the unwanted words and characters before I open each file for final processing in Pages. I found a set of Automator actions for TextEdit which includes a Find & Replace action, but I've wasted over an hour so far trying to get it to work.
    When I run the workflow, it acts like it's doing something, but the files remain unchanged. I have tried using actions such as Read Text File, Get Contents of TextEdit Document, Set Contents of TextEdit Document, along with 6 instances of Find & Replace, but I cannot get it to work.
    I'm at a point today where I cannot afford to mess around with this anymore. I have to do it the long way in Pages or else I'll never get it done, but I want to get these Automator workflows to work before I have to repeat this task. (I do this at least once a week right now.)
    Any ideas or suggestions? I've tried reading in the help menus and support pages, but perhaps I'm just not understanding something here.

    Any ideas or suggestions?
    You might be interested in using TextWrangler. It can perform batch find-and-replace changes across multiple selected files.
    Good luck!
    Andrew99

  • Powershell program to upload multiple files with version control at the file level

    I have a network folder which contains multiple files refreshed daily.I then run a power
    shell scrip which uploads all the files . I have scheduled it to run once
    daily. I have version control at the directory level , is there a way to upload all the files daily and maintain the last X versions for each file , rite now it does it at a folder level . I want it at a file level
    powershell script
    if((Get-PSSnapin "Microsoft.SharePoint.PowerShell") -eq $null)
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    #Script settings
    $webUrl = "http://sharepoint.contoso.com/Corporate/Sales/"
    $docLibraryName = "Shared Documents"
    $docLibraryUrlName = "Shared Documents\arizona" # specify your subfolder url here
    $localFolderPath = "C:\Test"
    #Open web and library
    $web = Get-SPWeb $webUrl
    write-host $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    write-host $docLibrary
    $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()
    write-host $files
    ForEach($file in $files)
    if($file.Name.Contains(".pdf"))
    write-host $file
    #Open file
    try
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
    #Add file
    $folder = $web.getfolder($docLibraryUrlName)
    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name,[System.IO.Stream]$fileStream, $true)
    write-host "Success"
    #Close file stream
    $fileStream.Close();
    catch
    Write "Error: $file.name: $_" >>c:\logfile.txt
    continue;
    #Dispose web
    $web.Dispose()

    Check if this helps you
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/04/28/weekend-scripter-use-powershell-to-upload-a-sharepoint-file-version.aspx
    # Add the Snapin
    Add-PSSnapin Microsoft.SharePoint.PowerShell
    # Retrieve specific Site
    $spWeb = Get-SPWeb http://SP01
    # Create instance of Folder
    $spFolder = $spWeb.GetFolder("Shared Documents")
    # Get the file on Disk that we want to upload
    $file = Get-Item C:\Documents\MyDoc.docx
    # upload the file.
    $spFolder.Files.Add("Shared Documents/MyDoc.docx",$file.OpenRead(),$false)
    $newVersion = $spFolder.Files.Add($spFile.Name, $file.OpenRead(), $spFile.Author, $spFile.ModifiedBy, $spFile.TimeCreated, (Get-Date))
    If this helped you resolve your issue, please mark it Answered

  • Batch code for running a find/replace all on multiple files within a source floder/directory

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

    What I need is a Batch source code that will open all files in a folder/directory and run a find and replace_all query within them and then save all the files.  The files were created in Illustrator and saved using the Scene7 FXG format extension.    These files will be uploaded into Scene7 as a group after the find and replace macro/query is run on the code.  The same find and replace query will be the same for all the files.  Basically this function or batch process  will save time in setting the same parameters all at one time instead of having to set the parameters individually in scene7.
    a source code sample of the find/replace module macro might be              searchString:  s7:colorvalue="#FFFFFFFF" 
                                                                                                                          replaceString: s7:colorValue="#&txtclr;"
                                                                                                                          searchWhat   "FXG document"    
                                                                                                                             searchSource:  true,
                                                                                                                        useRegularExpressions:   true
    I have no problems creating batch files within Ai and PhotoShop but I have limited programming skills in how to create source code for manuipulating documents outside of those apps or in a OS invironment.
    I could probably come up witha simple program to do what i want for one document but i get lost when dealing with multiple documents in a source folder (prolbem is,  I will be dealing with thousands of documents not 100 or less)
    If anything which Adope cloud app would work best:  Dreamweaver or Edge code   (or just use my notepad)

  • Find and Replace text in several files

    Can automator do that?
    I made a website in iweb and as the ones of you that had already tried it must know, it is impossible to change the font format on the links, you have to hack the code manually, changing the .css files.
    I think a trick would be to get automator to replace the code automatically, to lock for a string of text inside a group of files and save it. I just don't know how to do it. Can anybody help?
    The most I have been able to do is to get automator to open all .css files within a folder, inlcuidng all subfolders and open them on textedit.

    I doubt anyone is going to download and look at your code. Please remember that anyone who helps you here is a volunteer, and so the onus is on you to make helping you as easy as possible to do. That means you must take the effort to pare your code down to the bare minimum that shows your problem and compiles, and then post this code here. If you do decide to do this, please use code tags by highlighting your code after pasting it, and then pressing the Code button just above the editor window.
    Good luck.

  • How to replace text in a file

    Hi everyone,
    I have a txt file and It has some data's. I want to specifically replace a character in the text file. Data's will be like this,
    TT=15
    S1ST=21601
    S1EN=50400
    S2ST=50401
    S2EN=72000
    S3ST=72001
    S3EN=21600
    GNST=00000
    GNEN=00000
    S1B1S=22800
    S1B1E=23400
    S1B2S=28800
    S1B2E=30600
    S1B3S=36000
    S1B3E=36600
    S1B4S=45000
    S1B4E=46800
    In the 2nd line i.e. S1ST=21601, I want to replace 36000 instead of 21601.
    After replacing the specific character, data's should overwrite in the file or appending the file will also ok for me.
    Give me a suggestion. I am using LV 8.2. So plz post your code in 8.2 ver
    Thanks in advance.
    Regards,
    Vijay
    Solved!
    Go to Solution.

    Check this out.
    Edit:- attaching 8.2 version
    With Regards
    Miraz
    Kudos is better option to thank somebody on this forum
    Attachments:
    String.vi ‏8 KB
    String.vi ‏8 KB

  • Help with Replacing text in a file using a vbscript

    I have the following script which I am wanting to
    1. Take the prf file and read it
    2. Edit a line in the  outlook .prf file replacing it with the text I have asked it to replace which is the full name of the user pulled from the currently logged on user
    The problem I am seeing is that when the temp file is being generated it is throwing off the formatting of the file hence the script doesn't work. Can anyone help me please.
    set objSysInfo = CreateObject("ADSystemInfo")
    struser = objSysInfo.Username
    set objUser = GetObject("LDAP://" & strUser)
    strFullName = objUser.Get("displayName")
    Const ForReading=1
    Const ForWriting=2
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    folder = "C:\test"
    'filePath = folder & "file.txt"
    filePath = "c:\test\test2007_3.prf"
    Set myFile = objFSO.OpenTextFile(filePath, ForReading)
    Set myTemp= objFSO.OpenTextFile(filePath & ".tmp", ForWriting, True)
    Do While Not myFile.AtEndofStream
    myLine = myFile.ReadLine
     If InStr(myLine, "MailboxName=%UserName%") Then
      myLine = "&strFullName"
     End If
     myTemp.WriteLine myLine
    Loop
    myFile.Close
    myTemp.Close
    objFSO.DeleteFile(filePath)
    objFSO.MoveFile filePath& ".tmp", filePath
    Christopher

    Sorry Irv,
    Here is the code I have and then after that is the prf file. I think there is an issue with the file structure because if I take a regular text file and add the lines in there myself it replaces the lines, but with the prf file or even the prf file as a
    text file it gives me the invalid argument message
    Const filePath = "c:\test\test2007_3.txt"
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set myFile = objFSO.OpenTextFile(filePath)
    fileText = myFile.ReadAll()
    myFile.Close
    fileText=Replace(fileText,"%UserName%","THIS_IS_THS_REPLACEMENT_TEXT")
     Set myTemp= objFSO.OpenTextFile(filePath, 2, True)
     myTemp.Write fileText
     myTemp.Close
    ;Automatically generated PRF file from the Microsoft Office Customization and Installation Wizard
    ; Section 1 - Profile Defaults
    [General]
    Custom=1
    ProfileName=Somthing
    DefaultProfile=Yes
    OverwriteProfile=Yes
    ModifyDefaultProfileIfPresent=false
    DefaultStore=Service1
    ; Section 2 - Services in Profile
    [Service List]
    ServiceX=Microsoft Outlook Client
    ServiceEGS=Exchange Global Section
    Service1=Microsoft Exchange Server
    ServiceEGS=Exchange Global Section
    ; Section 3 - List of internet accounts
    [Internet Account List]
    ; Section 4 - Default values for each service.
    [ServiceX]
    CachedExchangeMode=0x00000002
    CachedExchangeSlowDetect=true
    [ServiceEGS]
    CachedExchangeConfigFlags=0x00000900
    MailboxName=%UserName%
    HomeServer=
    RPCoverHTTPflags=0x0027
    RPCProxyServer=
    RPCProxyPrincipalName=
    RPCProxyAuthScheme=0x0001
    [Service1]
    OverwriteExistingService=No
    UniqueService=Yes
    MailboxName=%UserName%
    HomeServer=
    OfflineAddressBookPath=%USERPROFILE%\local settings\application data\microsoft\outlook\
    OfflineFolderPathAndFilename=%USERPROFILE%\local settings\application data\microsoft\outlook\outlook.ost
    AccountName=Microsoft Exchange Server
    DefaultAccount=TRUE
    ;[ServiceX]
    ;FormDirectoryPage=
    ;-- The URL of Exchange Web Services Form Directory page used to create Web forms.
    ;WebServicesLocation=
    ;-- The URL of Exchange Web Services page used to display unknown forms.
    ;ComposeWithWebServices=
    ;-- Set to true to use Exchange Web Services to compose forms.
    ;PromptWhenUsingWebServices=
    ;-- Set to true to use Exchange Web Services to display unknown forms.
    ;OpenWithWebServices=
    ;-- Set to true to prompt user before opening unknown forms when using Exchange Web Services.
    ; Section 5 - Values for each internet account.
    ; Section 6 - Mapping for profile properties
    [Microsoft Exchange Server]
    ServiceName=MSEMS
    MDBGUID=5494A1C0297F101BA58708002B2A2517
    MailboxName=PT_STRING8,0x6607
    HomeServer=PT_STRING8,0x6608
    OfflineAddressBookPath=PT_STRING8,0x660E
    OfflineFolderPathAndFilename=PT_STRING8,0x6610
    [Exchange Global Section]
    SectionGUID=13dbb0c8aa05101a9bb000aa002fc45a
    MailboxName=PT_STRING8,0x6607
    HomeServer=PT_STRING8,0x6608
    RPCoverHTTPflags=PT_LONG,0x6623
    RPCProxyServer=PT_UNICODE,0x6622
    RPCProxyPrincipalName=PT_UNICODE,0x6625
    RPCProxyAuthScheme=PT_LONG,0x6627
    CachedExchangeConfigFlags=PT_LONG,0x6629
    [Microsoft Mail]
    ServiceName=MSFS
    ServerPath=PT_STRING8,0x6600
    Mailbox=PT_STRING8,0x6601
    Password=PT_STRING8,0x67f0
    RememberPassword=PT_BOOLEAN,0x6606
    ConnectionType=PT_LONG,0x6603
    UseSessionLog=PT_BOOLEAN,0x6604
    SessionLogPath=PT_STRING8,0x6605
    EnableUpload=PT_BOOLEAN,0x6620
    EnableDownload=PT_BOOLEAN,0x6621
    UploadMask=PT_LONG,0x6622
    NetBiosNotification=PT_BOOLEAN,0x6623
    NewMailPollInterval=PT_STRING8,0x6624
    DisplayGalOnly=PT_BOOLEAN,0x6625
    UseHeadersOnLAN=PT_BOOLEAN,0x6630
    UseLocalAdressBookOnLAN=PT_BOOLEAN,0x6631
    UseExternalToHelpDeliverOnLAN=PT_BOOLEAN,0x6632
    UseHeadersOnRAS=PT_BOOLEAN,0x6640
    UseLocalAdressBookOnRAS=PT_BOOLEAN,0x6641
    UseExternalToHelpDeliverOnRAS=PT_BOOLEAN,0x6639
    ConnectOnStartup=PT_BOOLEAN,0x6642
    DisconnectAfterRetrieveHeaders=PT_BOOLEAN,0x6643
    DisconnectAfterRetrieveMail=PT_BOOLEAN,0x6644
    DisconnectOnExit=PT_BOOLEAN,0x6645
    DefaultDialupConnectionName=PT_STRING8,0x6646
    DialupRetryCount=PT_STRING8,0x6648
    DialupRetryDelay=PT_STRING8,0x6649
    [Personal Folders]
    ServiceName=MSPST MS
    Name=PT_STRING8,0x3001
    PathAndFilenameToPersonalFolders=PT_STRING8,0x6700 
    RememberPassword=PT_BOOLEAN,0x6701
    EncryptionType=PT_LONG,0x6702
    Password=PT_STRING8,0x6703
    [Unicode Personal Folders]
    ServiceName=MSUPST MS
    Name=PT_UNICODE,0x3001
    PathAndFilenameToPersonalFolders=PT_STRING8,0x6700 
    RememberPassword=PT_BOOLEAN,0x6701
    EncryptionType=PT_LONG,0x6702
    Password=PT_STRING8,0x6703
    [Outlook Address Book]
    ServiceName=CONTAB
    [LDAP Directory]
    ServiceName=EMABLT
    ServerName=PT_STRING8,0x6600
    UserName=PT_STRING8,0x6602
    UseSSL=PT_BOOLEAN,0x6613
    UseSPA=PT_BOOLEAN,0x6615
    EnableBrowsing=PT_BOOLEAN,0x6622
    DisplayName=PT_STRING8,0x3001
    ConnectionPort=PT_STRING8,0x6601
    SearchTimeout=PT_STRING8,0x6607
    MaxEntriesReturned=PT_STRING8,0x6608
    SearchBase=PT_STRING8,0x6603
    CheckNames=PT_STRING8,0x6624
    DefaultSearch=PT_LONG,0x6623
    [Microsoft Outlook Client]
    SectionGUID=0a0d020000000000c000000000000046
    FormDirectoryPage=PT_STRING8,0x0270
    WebServicesLocation=PT_STRING8,0x0271
    ComposeWithWebServices=PT_BOOLEAN,0x0272
    PromptWhenUsingWebServices=PT_BOOLEAN,0x0273
    OpenWithWebServices=PT_BOOLEAN,0x0274
    CachedExchangeMode=PT_LONG,0x041f
    CachedExchangeSlowDetect=PT_BOOLEAN,0x0420
    [Personal Address Book]
    ServiceName=MSPST AB
    NameOfPAB=PT_STRING8,0x001e3001
    PathAndFilename=PT_STRING8,0x001e6600
    ShowNamesBy=PT_LONG,0x00036601
    ; Section 7 - Mapping for internet account properties.  DO NOT MODIFY.
    [I_Mail]
    AccountType=POP3
    ;--- POP3 Account Settings ---
    AccountName=PT_UNICODE,0x0002
    DisplayName=PT_UNICODE,0x000B
    EmailAddress=PT_UNICODE,0x000C
    ;--- POP3 Account Settings ---
    POP3Server=PT_UNICODE,0x0100
    POP3UserName=PT_UNICODE,0x0101
    POP3UseSPA=PT_LONG,0x0108
    Organization=PT_UNICODE,0x0107
    ReplyEmailAddress=PT_UNICODE,0x0103
    POP3Port=PT_LONG,0x0104
    POP3UseSSL=PT_LONG,0x0105
    ; --- SMTP Account Settings ---
    SMTPServer=PT_UNICODE,0x0200
    SMTPUseAuth=PT_LONG,0x0203
    SMTPAuthMethod=PT_LONG,0x0208
    SMTPUserName=PT_UNICODE,0x0204
    SMTPUseSPA=PT_LONG,0x0207
    ConnectionType=PT_LONG,0x000F
    ConnectionOID=PT_UNICODE,0x0010
    SMTPPort=PT_LONG,0x0201
    SMTPSecureConnection=PT_LONG,0x020A
    ServerTimeOut=PT_LONG,0x0209
    LeaveOnServer=PT_LONG,0x1000
    [IMAP_I_Mail]
    AccountType=IMAP
    ;--- IMAP Account Settings ---
    AccountName=PT_UNICODE,0x0002
    DisplayName=PT_UNICODE,0x000B
    EmailAddress=PT_UNICODE,0x000C
    ;--- IMAP Account Settings ---
    IMAPServer=PT_UNICODE,0x0100
    IMAPUserName=PT_UNICODE,0x0101
    IMAPUseSPA=PT_LONG,0x0108
    Organization=PT_UNICODE,0x0107
    ReplyEmailAddress=PT_UNICODE,0x0103
    IMAPPort=PT_LONG,0x0104
    IMAPUseSSL=PT_LONG,0x0105
    ; --- SMTP Account Settings ---
    SMTPServer=PT_UNICODE,0x0200
    SMTPUseAuth=PT_LONG,0x0203
    SMTPAuthMethod=PT_LONG,0x0208
    SMTPUserName=PT_UNICODE,0x0204
    SMTPUseSPA=PT_LONG,0x0207
    ConnectionType=PT_LONG,0x000F
    ConnectionOID=PT_UNICODE,0x0010
    SMTPPort=PT_LONG,0x0201
    SMTPSecureConnection=PT_LONG,0x020A
    ServerTimeOut=PT_LONG,0x0209
    CheckNewImap=PT_LONG,0x1100
    RootFolder=PT_UNICODE,0x1101
    [INET_HTTP]
    AccountType=HOTMAIL
    Account=PT_UNICODE,0x0002
    HttpServer=PT_UNICODE,0x0100
    UserName=PT_UNICODE,0x0101
    Organization=PT_UNICODE,0x0107
    UseSPA=PT_LONG,0x0108
    TimeOut=PT_LONG,0x0209
    Reply=PT_UNICODE,0x0103
    EmailAddress=PT_UNICODE,0x000C
    FullName=PT_UNICODE,0x000B
    Connection Type=PT_LONG,0x000F
    ConnectOID=PT_UNICODE,0x0010
    Christopher

  • Need to create multiple files in CSV through UTL_File package

    I have to extract data from table from csv format and maximum number should be 10 each file.how to do this through UTL_File utilities.
    i am putting the code...any input would be apprecaited...
    CREATE OR REPLACE PACKAGE BODY TEST
    AS
    PROCEDURE main_test(
    errbuff OUT VARCHAR2,
    retcode OUT VARCHAR2
    IS
    -- Variables
    lv_file_handle UTL_FILE.FILE_TYPE;
    lv_file_name_txt VARCHAR2(25);
    lv_file_location_txt VARCHAR2(100) :='/dv1/gfp/ora01/dv1gfpcomn/temp';
    v_error_code NUMBER;
    v_error_text VARCHAR2(200);
    lv_cursor_rowcnt NUMBER := 0;
    lv_row_data VARCHAR2(32000);
    lv_row_tran_data VARCHAR2(32000);
    lv_transaction_number VARCHAR2(1000);
    lv_row_head_data1 VARCHAR2(32000);
    lv_row_trn_data1 VARCHAR2(32000);
    lv_row_data1 VARCHAR2(32000);
    lv_period VARCHAR2(100);
    row_cnt number := 0;
    c integer;
    max_rows number;
    -- Cursors
    CURSOR cur_period IS
    select
    user_name name,
    description description ,
    email_address email,
    start_date st_date,
    end_date end_date
    from fnd_user
    WHERE ROWNUM <51
    ORDER BY 1,4 desc;
    BEGIN
    lv_file_name_txt := 'test'||TO_CHAR (SYSDATE, 'DDMMYYYY')||'.txn';
    lv_file_handle := UTL_FILE.FOPEN(lv_file_location_txt, lv_file_name_txt, 'w');
    --code modification here
    FOR cur_rec IN cur_period
    LOOP
    lv_row_data := NULL;
    lv_cursor_rowcnt := lv_cursor_rowcnt + 1;
    lv_row_data := rpad(nvl(substr(cur_rec.name,1,10),'') ,10,' ') || '+'
    || rpad(nvl(substr(cur_rec.description,1,10),'') ,10,' ') || '+'
    || rpad(nvl(substr(cur_rec.email,1,15),'') ,15,' ') || '+'
    || rpad(nvl(substr( cur_rec.st_date,1,10),'') ,10,' ') || '+'
    || rpad(nvl(substr( cur_rec.end_date ,1,10),'') ,10,' ') ;
    END LOOP;
    IF lv_cursor_rowcnt = 0 THEN
    fnd_log.put_line ('No data found');
    END IF;
    UTL_FILE.FCLOSE(lv_file_handle);
    EXCEPTION
    WHEN OTHERS
    THEN
    v_error_code := SQLCODE;
    v_error_text := SQLERRM;
    retcode := 2;
    fnd_log.put_line ('s-Error :' || v_error_code || '- ' || v_error_text );
    fnd_log.put_line (SQLERRM);
    UTL_FILE.FCLOSE_ALL();
    END;
    END TEST;
    show err
    ---

    Hi,
    and maximum number should be 10 each file.utilities. I could not understand the above line. If you want to put 10 rows in one file , next 10 rows in another file and so on ......
    There are two approaches.
    1. Simple one is store all records in one file using UTL_FILE and then use unix
    split utility to break 10 lines for each file.
    2. Store all files name is an array ( VARRAY or Associative Arrays) .
    (i) Fetch file name form Array
    (ii) Open a File
    (iii) Store 10 rows in File
    (iv) Close file. Go to step 1.
    Regards

  • How do I find and replace text in PHP files?

    How can I in CS3 make sitewide changes to the text in PHP pages without changing variable names etc that have the same name?
    For example if I have an installation of a PHP forum and I want to change every instance of the word 'forum' to 'message board'...
    If I used the 'inside tag' search with " as the tag, then if "" contained a variable called 'forum' it would also be changed and therefore corrupt the code....
    Is there a simple way around this?
    Thanks!
    I'm using CS3 on Windows Vista.

    It looks like you're trying to find and replace source code, so you may be able to look at the various places that are looked at when finding and uncheck the ones that don't apply.
    But, if it's all source code then that won't help.  One thing that may work is to expand the search option - for example if the work "forum" that you're wanting to change it preceded by another word, or character or something that sets it apart, then do you find on that. You can expand that search phrase as far out in either direction that you need to to make it different, if of course that is practical in your situation.
    The only other way I can think of is to somehow create an exception rule, but I'm not sure if that's possible or how to do it.

  • Help with Automator to copy text from multiple files

    Hello,
    I'm new to automator and applescript but it seems like what I'm trying to accomplish is fairly easy.
    I'd like to run a workflow that will open a text file, copy the contents, paste the contents into a given application and then take a screenshot.
    I'd like to be able to do this for several hundred text files.
    I've tried with a Service but can't figure out how to provide the text input after "Get Specified Finder Items".
    Get Specified Finder Items --> Get Contents of TextEdit Document --> Copy to Clipboard --> results in no data.

    You'll need to use Applescript (you could use the Automator Run Applescript Action).
    set recipientAddress to do shell script "cat <filename.txt>"
    set theSubject to "Type your subject here!"
    set theContent to "Type your message content here!"
    tell application "Mail"
      activate
              set theMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
              tell theMessage
      make new to recipient with properties {address:recipientAddress}
      -- Uncomment send to Send the Message:
      -- send
              end tell
    end tell

  • [Bash] Massively replace text in all files of a directory

    Hi everybody,
    I wrote this small recursive function in order to massively replace some strings contained in all files of a directory (and all subdirectories). Any suggestions?
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local script="$2"
    local opts="${@:3}"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $opts "s/$(echo $script)/g" "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    browse $1
    Syntax:
    replaceText [path] [script] [sed options (optional)]
    For example (it will replace "hello" with "hi" in all files):
    replaceText /home/user/mydir hello/hi
    Note: It is case-sensitive.
    Bye,
    grufo
    Last edited by grufo (2012-11-10 15:05:43)

    falconindy wrote:
    Yes, find is recursive and extremely good at its job.
    http://mywiki.wooledge.org/UsingFind
    Well
    falconindy wrote:Your lack of quoting is dangerous, as is your code injection in sed. I'm not sure why you're echoing a var inside a command substitution inside a sed expression, but it's going to be subject to word splitting, all forms of expansion, and may very well break the sed expression entirely, leading to bad things. A contrived example, but passing something like 'foo//;d;s/bar/' should effectively delete the contents of every file the function touches.
    So, if you consider it dangerous, you can adopt the whole "sed syntax" and confirm before continue...:
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local sedArgs="${@:2}"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $sedArgs "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    while true; do
    read -p "Do you want to apply \"sed $sedArgs\" to all files contained in the directory $1? [y/n] " yn
    case $yn in
    [Yy]* ) browse $1; break;;
    * ) exit;;
    esac
    done
    Syntax:
    replaceText [parent directory] [sed arguments]
    Example:
    replaceText /your/path -r 's/OldText/NewText/g'
    or, if you want to work directly with the current directory...
    replaceText() {
    # set the temporary location
    local tFile="/tmp/out.tmp.$$"
    # call variables
    local sedArgs="$@"
    browse() {
    for iFile in "$1"/*; do
    if [ -d "$iFile" ];then
    # enter subdirectory...
    browse "$iFile"
    elif [ -f $iFile -a -r $iFile ]; then
    echo "$iFile"
    sed $sedArgs "$iFile" > $tFile && mv $tFile "$iFile"
    else
    echo "Skip $iFile"
    fi
    done
    while true; do
    read -p "Do you want to apply \"sed $sedArgs\" to all files contained in the directory $PWD? [y/n] " yn
    case $yn in
    [Yy]* ) browse $PWD; break;;
    * ) exit;;
    esac
    done
    Syntax:
    replaceText [sed arguments]
    Example:
    replaceText -r 's/OldText/NewText/g'
    What about?
    falconindy wrote:I'll also point out that declaring a function within a function doesn't provide any amount of scoping -- 'browse' will be declared in the user's namespace after running this function for the first time.
    See:
    function1() {
    function2() {
    echo "Ciao"
    function2
    function2 # error
    function1 # works

  • Replace text in pdf files by sript

    Hi,
    I have a huge number of pdf files.
    There is a phone number in which has to be changed.
    Is there a way to do this using a script or any other kind of automation?
    Thanks.

    It can probably be done in Acrobat Pro using an Action and a script, but processing a large number of files in Acrobat is problematic.
    You would probably need a stand-alone tool to do it.

  • Newbie question: how to replace a bunch of text in a file?

    Good afternoon,
    I have a very stupid problem here: I want to replace text in a file.
    At first glance, this is very simple: just do:
    sed -e 's/letter_a/alpha/g' test.txt > test2.txt
    and the word "letter_a" will be replaced by the word "alpha" everywhere in the file "test.txt" and the results will be placed in file "test2.txt".
    However my problem is a bit more complex:
    I want to do different replacements in one file.
    If I do:
    sed -e 's/letter_a/alpha/g' test.txt
    then the result will be shown on my screen, but I want the results to be stored in my file "test.txt".
    I have already tried to do:
    sed -e 's/letter_a/alpha/g' test.txt > test.txt
    but this simply empties the file "test.txt".
    As I have more than 50 replacements to do, I cannot do something like:
    sed -e 's/letter_a/alpha/g' test.txt > test1.txt
    sed -e 's/letter_b/beta/g' test1.txt > test2.txt
    sed -e 's/letter_c/gamma/g' test2.txt > test3.txt
    +...+
    mv test50.txt test.txt
    rm test1.txt
    +...+
    rm test50.txt
    (It's possible in theory, but it's really too much work)
    Do you know an easy command that does the following:
    Replace "letter_a" by "alpha" in <filename> (without needing to specify another file where the output will be written)?
    Thanks
    Dominique
    Edited by: scampsd on Oct 5, 2011 5:17 PM

    Why don't you write a wrapper script that renames the input file to a temp file and run the sed to the original name. Something like:
    <pre>
    #!/bin/sh
    # $1 = old string
    # $2 = new string
    # $3 = input/output file
    cp -p $3 $3.zz$$ # preserves i-node of file
    sed -e s/"$1"/"$2"/g < $3.zz$$ > $3
    rm $3.zz$$
    </pre>

  • Running OCR on Combined document saves no text to .txt file

    I am scanning in a large 500 page document, running OCR on it and saving the data to a text file for my program to process.
    My network printer/copier/scanner can only read in about 70 pages at a time, so I scanned in as several PDF documents, which I saved to disk.
    I   Recognize Text in Multiple Files using OCR...   on all of the PDF documents, Saving-As Text (Accessable) and it all works fine. I can then combine the text files in a text processor.
    Then, I saw the Combine button, so I combined all of the PDF documents into a separate PDF file and ran OCR on it, but the resulting .txt file is blank!  If I run the OCR manually, I can highlight the extract text, but when I try to save as Text (Accessable), it still fails to save any data to the .txt file.
    Is this a known problem?
    I am running Adobe Acrobat 9 Pro - Version 9.4.5.
    Thanks.

    gilgad2000,
    It depends on your VI. If you are using the "Path Control" tool, you can open its "Browse Options" and write .txt at the Pattern box.
    If you are not using it, you can also concatenate a ".txt" string at the end of the file path (use "Strip Path", "Concatenate Strings" and "Build Path" functions) just before using it on the saving function.
    Message Edited by Danigno on 07-17-2009 03:18 AM
    Attachments:
    Snap1.png ‏3 KB

Maybe you are looking for

  • The Document Enabled Extended Features in Adobe Reader.

    Hi Experts, We are facing a problem while opening a PDF form that is editable. get below error message: The Document Enabled Extended Features in Adobe Reader,  The document has been changed since it was created & use of extended features is no longe

  • Comparing column values within same row

    Script <code> create table testp ( name varchar2(20), yr1 number, yr2 number, yr3 number, yr4 number); insert into testp values ('Jana',500,400,300,900); insert into testp values ('sarat',200,300,800,100); commit; <code> I need the result like this <

  • Importing pics

    I am trying to import pics from the iPhoto library folder to the iPhoto library or a new album. When I do, i get a dialog box that states "can not import, file already exists in iPhoto library folder". Ihave tried clicking and dragging with the same

  • Is there a way to see what devices are using your email from imessage?

    I sent a personal message to a friend of mine and I want to make sure no one else in my icloud account would be able to recieve it to

  • How do I make an Acrobat 10 package for deployment or image?

    I'm not sure how to do it, since there is no customization wizard for Mac, thanks