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

Tracking if file renames work or not

$
0
0

Brand new to Powershell...  :)

I'm working on automating some steps that we do that involve renaming a whole bunch of files.  I want to code it in so that it can just go through and rename them all, but I need to know if each rename worked or not.

Ideally I'd want to just output something like

Folder   Result
------   ------
Folder1   OK
Folder2   Error

I don't see that the Rename command actually can return a True/False to say if it worked or not so I figured I can put each Rename-Item into its own Try/Catch and the Catch statement could put in Error and if it didn't have an error I could put in OK somehow.

Just looking for some ideas for how I can make this work and look decent. :)

Thanks!


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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