Rename files and move to a folder

This topic contains 3 replies, has 3 voices, and was last updated by  edwin arlington 2 weeks, 6 days ago.

  • Author
    Posts
  • #78748

    Hris
    Participant

    Hello i'm trying for a while to rename pdf files that are like letters in the beginning and in the end date: example_if_name_04.09.2017.pdf. I want to rename all of them to date 04_09_2017.pdf or 04092017.pdf.

    I did something like this:

    $z = Get-ChildItem c:\fso -Filter *.pdf -Recurse | % { $_.FullName }
    $files = $a -replace '[^0-9]', "

    foreach($i in $files)
    {
    $d = $i+".pdf"
    Rename-Item $z $i -WhatIf
    }

  • #78755

    random commandline
    Participant
    # Replace dot with underscore and keep extension
    Get-ChildItem C:\fso -Filter *.pdf | Rename-Item -NewName {
        ($_.BaseName -replace '\.','_') + $_.Extension}
    
  • #78760

    Hris
    Participant

    Thanks, done it with this:

    Get-ChildItem C:\fso -Filter *.pdf | Rename-Item -NewName {
        ($_.BaseName -replace '[^0-9]', '') + $_.Extension}
  • #78793

    edwin arlington
    Participant

    You can try the below command:

    In DOS /CMD

    move file.ext \\server\folder\newfile.ext

    move /?

    In PowerSHell:

    Move-Item file.ext \\server\folder\newfile.ext

    Move-Item -?

    In VBScript:

    fso.MoveFile "file.ext:, "\\server\folder\newfile.ext"

    For more information, please checkout the below articles:

    http://technet.microsoft.com/en-us/library/ee176940.aspx

    http://technet.microsoft.com/en-us/library/ee176910.aspx

You must be logged in to reply to this topic.