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

Move files with *1234*.txt in the filename and rename the newest file to 1234.txt

$
0
0

Hi experts,

I have a funny scenario,

I have folder with multiple files.
I want to move all the files that has 1234 in the filename to a new folder and rename the newest file to 1234.txt

Example:
I have this three files in a folder, i wish to copy all of them to another folder and rename the newest file to 1234.txt
1. abc-1234-abc.txt             /created at 2015
2. def-1234-def.txt              /created at 2013
3. ghi-1234-ghi.txt              /created at 2011

I have tried this in CMD but it dose not rename the newest file:
move *1234*.* C:\Users\guyo | dir /o-d c:\users\guyo | ren c:\users\guyo\*1234*.* 1234.txt

Does it even possible with CMD?

How can i run it in power shell?


Viewing all articles
Browse latest Browse all 21975

Trending Articles



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