none
Replace a word with blank in multiple files RRS feed

  • Question

  • I have multiple files with this name:
    processed.ABC.All_20170310_100033.txt
    processed.ABC.All_20170310_090001.txt
    processed.ABC.All_20170310_110015.txt

    How can I replace them with these file names (replace "processed." with blank) :
    ABC.All_20170310_100033.txt
    ABC.All_20170310_090001.txt
    ABC.All_20170310_110015.txt

    Can I do it using a command prompt ?

    Thank you.


    • Edited by aujong Friday, March 10, 2017 4:48 PM
    Friday, March 10, 2017 4:47 PM

Answers

  • Thank you.
    The time stamp in the files are different each time, ie 
    20170310_100033
    20170310_09000120170310_110015
    , etc.

    I ended up doing it using this PowerShell command:

    Dir |
    Rename-Item -NewName { $_.Name -replace "processed.","" }
    Friday, March 10, 2017 5:31 PM

All replies

  • for each in containing folder -> read filename -> strip leading 10 characters matching (processed.) -> rename file with new filename -> next
    Friday, March 10, 2017 5:00 PM
  • How do you do that in a command prompt ?
    Friday, March 10, 2017 5:08 PM
  • How do you do that in a command prompt ?

    C:\>ren "processed.ABC.All_20170310_100033.txt" "ABC.All_20170310_100033.txt"

    Repeat for each file name.


    -- Bill Stewart [Bill_Stewart]

    Friday, March 10, 2017 5:22 PM
    Moderator
  • Thank you.
    The time stamp in the files are different each time, ie 
    20170310_100033
    20170310_09000120170310_110015
    , etc.

    I ended up doing it using this PowerShell command:

    Dir |
    Rename-Item -NewName { $_.Name -replace "processed.","" }
    Friday, March 10, 2017 5:31 PM