Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

to move files and rename if needed

$
0
0

Hi,

I would like to automate moving files from one machine to another using powershell that seems to be easy to accomplish by Move-Item, but I need to use Rename-Item as well in case a file with the same name already exists on the target machine, preferably by adding a "-n" to the file name before the file name extension on the source or target machine (where n is a sequential number). This may take several turns and more time I guess, as even a file with the next sequential number could exist on the target machine.

I think to pass the source and target locations as arguments like "powershell move-files.ps1 arg1-source arg2-target" if there is no better way.

Can someone help me with the script?

Thank you.


Viewing all articles
Browse latest Browse all 2562

Trending Articles



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