petermolit
asked on
Powershell script to rename files in subdirectory's
I am looking for a Powershell script to rename files in subdirectory's.
For example:
\test1\file1
\test2\file1
\test3\file1
The 3 files in the 3 directory's should be renamed to file2 so after executing the script
\test1\file2
\test2\file2
\test3\file2
I want to run this .ps1 scriptfile from the commandline with parameters originalfilename and newfilename
For example:
\test1\file1
\test2\file1
\test3\file1
The 3 files in the 3 directory's should be renamed to file2 so after executing the script
\test1\file2
\test2\file2
\test3\file2
I want to run this .ps1 scriptfile from the commandline with parameters originalfilename and newfilename
you can use the ren command in a batch file like this (ren PATH\FILENAME PATH|FILENAME ) and repeat this command in the pathfile as long as your filenames
Have a look here for sample PowerShell scripts:
http://www.microsoft.com/technet/scriptcenter/scripts/msh/default.mspx?mfr=true
and, you can basically use the code from here:
http://geekswithblogs.net/tmurphy/archive/2007/07/18/Renaming-Groups-of-Files-With-PowerShell.aspx
which shows the use of input parameters.
I can help you complete that later if needed....
Regards,
Rob.
http://www.microsoft.com/technet/scriptcenter/scripts/msh/default.mspx?mfr=true
and, you can basically use the code from here:
http://geekswithblogs.net/tmurphy/archive/2007/07/18/Renaming-Groups-of-Files-With-PowerShell.aspx
which shows the use of input parameters.
I can help you complete that later if needed....
Regards,
Rob.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.