Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Get renamed file new name

$
0
0

Hello all. What I'm wanting to do is rename a file and then do some things with the new file name.

1. I want to view the new file name with the full path

2. I want to output the new file name with the full path to a text file or csv file

Here is what I have for outputting the renamed file into a text file, but it isn't working:

cls
$resultsfile = "C:\results3.txt"
clear-content $resultsfile

foreach($item in gc C:\RENAME.txt){

    Rename-Item  $item "1.txt" | out-file $resultsfile -append
}
notepad $resultsfile

Any thoughts on how to work with the newly renamed file name?

Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>