Copying files and renaming files into the original folder using Powershell -


i new scripting process. i've been googling problem on week, , have found snippets of pieces of need, can't figure out how put together.

i need following:

folder1/main.txt  folder1/subfolder/main.txt  folder2/main.txt  folder3/main.txt 

i need make copy of main.txt , rename temp.txt same folder... (except, have thousand of these files do!)

so have this:

folder1 > main.txt > temp.txt folder1/subfolder > main.txt > temp.txt  folder2 > main.txt > temp.txt  folder3 > main.txt > temp.txt 

any appreciated. thank you!

in powershell:

get-childitem 'c:\some\folder' -filter 'main.txt' -recurse | % {   copy-item $_.fullname (join-path $_.directory 'temp.txt') } 

in batch:

@echo off  /r "c:\some\folder" %%f in (main.txt) (   copy "%%~ff" "%%~dpftemp.txt" ) 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -